# HG changeset patch # User Timo Sirainen # Date 1030559884 -10800 # Node ID 12746cf2e4478b0152e4b59c293b4cae97b6b407 # Parent 0e58a036265ea62b23977d86f41731bb112f3575 More alignment fixes diff -r 0e58a036265e -r 12746cf2e447 src/lib/temp-mempool.c --- a/src/lib/temp-mempool.c Wed Aug 28 21:27:47 2002 +0300 +++ b/src/lib/temp-mempool.c Wed Aug 28 21:38:04 2002 +0300 @@ -48,7 +48,7 @@ MemBlock *next; unsigned int size, left; - unsigned char data[1]; + /* unsigned char data[]; */ }; /* current_stack contains last t_push()ed blocks. After that new @@ -159,7 +159,7 @@ prev_size = current_block == NULL ? 0 : current_block->size; alloc_size = nearest_power(prev_size + min_size); - block = malloc(sizeof(MemBlock)-1 + alloc_size); + block = malloc(MEM_ALIGN(sizeof(MemBlock)) + alloc_size); if (block == NULL) { i_panic("mem_block_alloc(): " "Out of memory when allocating %u bytes", @@ -196,7 +196,7 @@ if (current_block->left >= size) { /* enough space in current block, use it */ - ret = current_block->data + + ret = (char *) current_block + MEM_ALIGN(sizeof(MemBlock)) + (current_block->size - current_block->left); if (permanent) current_block->left -= size; @@ -219,7 +219,7 @@ current_block->next = block; current_block = block; - return current_block->data; + return (char *) current_block + MEM_ALIGN(sizeof(MemBlock)); } void *t_malloc(unsigned int size) @@ -239,9 +239,9 @@ int t_try_grow(void *mem, unsigned int size) { /* see if we want to grow the memory we allocated last */ - if (current_block->data + (current_block->size - - current_block->left - - last_alloc_size) == mem) { + if ((char *) current_block + MEM_ALIGN(sizeof(MemBlock)) + + (current_block->size - current_block->left - + last_alloc_size) == mem) { /* yeah, see if we can grow */ size = MEM_ALIGN(size); if (current_block->left >= size-last_alloc_size) {