Revision: 41929
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41929
Author:   campbellbarton
Date:     2011-11-16 19:17:33 +0000 (Wed, 16 Nov 2011)
Log Message:
-----------
better alignement for BLI_mempool struct

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenlib/BLI_mempool.h
    branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c

Modified: branches/bmesh/blender/source/blender/blenlib/BLI_mempool.h
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/BLI_mempool.h 2011-11-16 
19:06:38 UTC (rev 41928)
+++ branches/bmesh/blender/source/blender/blenlib/BLI_mempool.h 2011-11-16 
19:17:33 UTC (rev 41929)
@@ -48,8 +48,8 @@
   first four bytes of the elements never contain the character string
   'free'.  use with care.*/
 
-struct BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk,
-                                       int use_sysmalloc, int allow_iter);
+BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk,
+                                short use_sysmalloc, short allow_iter);
 void *BLI_mempool_alloc(BLI_mempool *pool);
 void *BLI_mempool_calloc(BLI_mempool *pool);
 void BLI_mempool_free(BLI_mempool *pool, void *addr);

Modified: branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c  
2011-11-16 19:06:38 UTC (rev 41928)
+++ branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c  
2011-11-16 19:17:33 UTC (rev 41929)
@@ -68,26 +68,29 @@
 
 typedef struct BLI_mempool {
        struct ListBase chunks;
-       int esize, csize, pchunk;               /*size of elements and chunks 
in bytes and number of elements per chunk*/
-       BLI_freenode *free;             /*free element list. Interleaved into 
chunk datas.*/
-       int totalloc, totused; /*total number of elements allocated in total, 
and currently in use*/
-       int use_sysmalloc, allow_iter;
+       int esize, csize, pchunk;        /* size of elements and chunks in bytes
+                                         * and number of elements per chunk*/
+       short use_sysmalloc, allow_iter;
+       /* keeps aligned to 16 bits */
+
+       BLI_freenode *free;                  /* free element list. Interleaved 
into chunk datas.*/
+       int totalloc, totused;           /* total number of elements allocated 
in total,
+                                         * and currently in use*/
 } BLI_mempool;
 
+#define MEMPOOL_ELEM_SIZE_MIN (sizeof(void *) * 2)
+
 BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk,
-                                int use_sysmalloc, int allow_iter)
+                                short use_sysmalloc, short allow_iter)
 {
        BLI_mempool  *pool = NULL;
        BLI_freenode *lasttail = NULL, *curnode = NULL;
        int i,j, maxchunks;
        char *addr;
-       
-       if (esize < sizeof(void*)*2)
-               esize = sizeof(void*)*2;
-       
-       if (esize < sizeof(void*)*2)
-               esize = sizeof(void*)*2;
 
+       if (esize < MEMPOOL_ELEM_SIZE_MIN)
+               esize = MEMPOOL_ELEM_SIZE_MIN;
+
        /*allocate the pool structure*/
        pool = use_sysmalloc ? malloc(sizeof(BLI_mempool)) : 
MEM_mallocN(sizeof(BLI_mempool), "memory pool");
        pool->esize = allow_iter ? MAX2(esize, sizeof(BLI_freenode)) : esize;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to