mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
bugfix: use memcpy for unalign memory
This commit is contained in:
@@ -7,4 +7,4 @@ memory.dump()
|
||||
print("Total memory:", memory.total())
|
||||
print("Total block:", memory.block())
|
||||
|
||||
skynet.exit()
|
||||
skynet.start(function() skynet.exit() end)
|
||||
|
||||
@@ -66,7 +66,7 @@ fill_prefix(char* ptr) {
|
||||
uint32_t handle = skynet_current_handle();
|
||||
size_t size = je_malloc_usable_size(ptr);
|
||||
uint32_t *p = (uint32_t *)(ptr + size - sizeof(uint32_t));
|
||||
*p = handle;
|
||||
memcpy(p, &handle, sizeof(handle));
|
||||
|
||||
update_xmalloc_stat_alloc(handle, size);
|
||||
return ptr;
|
||||
@@ -77,7 +77,8 @@ clean_prefix(char* ptr) {
|
||||
uint32_t* rawptr = (uint32_t*)ptr - 1;
|
||||
size_t size = je_malloc_usable_size(rawptr);
|
||||
uint32_t *p = (uint32_t *)(ptr + size - sizeof(uint32_t));
|
||||
uint32_t handle = *p;
|
||||
uint32_t handle;
|
||||
memcpy(&handle, p, sizeof(handle));
|
||||
update_xmalloc_stat_free(handle, size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user