PATCH: fix alignment in slab.c

dormando dormando at rydia.net
Mon Feb 11 06:01:13 UTC 2008


So what happens when a void* becomes bigger than 8 bytes? ;)

committed in r696

Trond Norbye wrote:
> The memory returned from do_slabs_alloc is currently not properly
> aligned when compiled in an ILP32 environment. The memory returned is
> aligned to the size of the pointers, but we need to return a pointer
> that is suitable aligned so that it may be assigned to a pointer to any
> type of object.
> 
> The cas_id member cause the item-struct to require 8 byte boundaries.
> 
> Index: slabs.c
> ===================================================================
> --- slabs.c     (revision 689)
> +++ slabs.c     (working copy)
> @@ -25,7 +25,7 @@
> #define POWER_SMALLEST 1
> #define POWER_LARGEST  200
> #define POWER_BLOCK 1048576
> -#define CHUNK_ALIGN_BYTES (sizeof(void *))
> +#define CHUNK_ALIGN_BYTES 8
> #define DONT_PREALLOC_SLABS
> 
> /* powers-of-N allocation structures */
> --------------END------------
> 



More information about the memcached mailing list