Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-11-16 23:17:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-16 23:17:33 +0400
commit508c7f3ebd4174cdba39b63984fe68e6d69bdda2 (patch)
tree36841efe5b30b7511bb255f26257e7323a7ad550 /source/blender/blenlib
parent9d05ccf9e84510ca7e3fe140f6e20991a931b8ce (diff)
better alignement for BLI_mempool struct
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_mempool.h4
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c25
2 files changed, 16 insertions, 13 deletions
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h
index 2f56bc87665..f98919fadd3 100644
--- a/source/blender/blenlib/BLI_mempool.h
+++ b/source/blender/blenlib/BLI_mempool.h
@@ -48,8 +48,8 @@ typedef struct BLI_mempool BLI_mempool;
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);
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 80b70dd45b6..3dbbec057b2 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -68,25 +68,28 @@ typedef struct BLI_mempool_chunk {
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");