Fix memory alignment
This commit is contained in:
parent
8dd8d1c312
commit
2b63360b95
|
@ -81,6 +81,7 @@ static void* memoryBlockMallocImpl(size_t size)
|
||||||
|
|
||||||
if (size != 0) {
|
if (size != 0) {
|
||||||
size += sizeof(MemoryBlockHeader) + sizeof(MemoryBlockFooter);
|
size += sizeof(MemoryBlockHeader) + sizeof(MemoryBlockFooter);
|
||||||
|
size += sizeof(int) - size % sizeof(int);
|
||||||
|
|
||||||
unsigned char* block = (unsigned char*)malloc(size);
|
unsigned char* block = (unsigned char*)malloc(size);
|
||||||
if (block != NULL) {
|
if (block != NULL) {
|
||||||
|
@ -123,6 +124,7 @@ static void* memoryBlockReallocImpl(void* ptr, size_t size)
|
||||||
|
|
||||||
if (size != 0) {
|
if (size != 0) {
|
||||||
size += sizeof(MemoryBlockHeader) + sizeof(MemoryBlockFooter);
|
size += sizeof(MemoryBlockHeader) + sizeof(MemoryBlockFooter);
|
||||||
|
size += sizeof(int) - size % sizeof(int);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* newBlock = (unsigned char*)realloc(block, size);
|
unsigned char* newBlock = (unsigned char*)realloc(block, size);
|
||||||
|
|
Loading…
Reference in New Issue