[Bf-blender-cvs] [af59ee3] master: Mempool: remove BLI_MEMPOOL_SYSMALLOC, MEM_* allocs are more efficient now
Campbell Barton
noreply at git.blender.org
Sat Apr 5 03:14:21 CEST 2014
Commit: af59ee340f8859bdcd5f09c54bcb48776adf0c0a
Author: Campbell Barton
Date: Sat Apr 5 10:57:32 2014 +1100
https://developer.blender.org/rBaf59ee340f8859bdcd5f09c54bcb48776adf0c0a
Mempool: remove BLI_MEMPOOL_SYSMALLOC, MEM_* allocs are more efficient now
===================================================================
M source/blender/blenkernel/intern/customdata.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/blenlib/BLI_linklist_stack.h
M source/blender/blenlib/BLI_mempool.h
M source/blender/blenlib/intern/BLI_ghash.c
M source/blender/blenlib/intern/BLI_mempool.c
M source/blender/blenlib/intern/edgehash.c
M source/blender/bmesh/intern/bmesh_edgeloop.c
M source/blender/bmesh/intern/bmesh_log.c
M source/blender/bmesh/intern/bmesh_mesh.c
M source/blender/bmesh/intern/bmesh_operators.c
M source/blender/bmesh/intern/bmesh_walkers.c
M source/blender/bmesh/operators/bmo_connect_pair.c
M source/blender/bmesh/operators/bmo_hull.c
M source/blender/bmesh/tools/bmesh_beautify.c
M source/blender/bmesh/tools/bmesh_edgenet.c
M source/blender/imbuf/intern/moviecache.c
===================================================================
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index a628504..41eb2f5 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -2408,7 +2408,7 @@ void CustomData_bmesh_init_pool(CustomData *data, int totelem, const char htype)
/* If there are no layers, no pool is needed just yet */
if (data->totlayer) {
- data->pool = BLI_mempool_create(data->totsize, totelem, chunksize, BLI_MEMPOOL_SYSMALLOC);
+ data->pool = BLI_mempool_create(data->totsize, totelem, chunksize, BLI_MEMPOOL_NOP);
}
}
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index bb3561d..0bdd786 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1189,8 +1189,7 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh, PBVHTopologyUpdateMode mode,
if (mode & PBVH_Collapse) {
EdgeQueue q;
- BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]),
- 128, 128, 0);
+ BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]), 128, 128, BLI_MEMPOOL_NOP);
EdgeQueueContext eq_ctx = {&q, queue_pool, bvh->bm, cd_vert_mask_offset};
short_edge_queue_create(&eq_ctx, bvh, center, radius);
@@ -1203,8 +1202,7 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh, PBVHTopologyUpdateMode mode,
if (mode & PBVH_Subdivide) {
EdgeQueue q;
- BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]),
- 128, 128, 0);
+ BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]), 128, 128, BLI_MEMPOOL_NOP);
EdgeQueueContext eq_ctx = {&q, queue_pool, bvh->bm, cd_vert_mask_offset};
long_edge_queue_create(&eq_ctx, bvh, center, radius);
diff --git a/source/blender/blenlib/BLI_linklist_stack.h b/source/blender/blenlib/BLI_linklist_stack.h
index ef78fb9..c2aefc3 100644
--- a/source/blender/blenlib/BLI_linklist_stack.h
+++ b/source/blender/blenlib/BLI_linklist_stack.h
@@ -56,7 +56,7 @@
#define BLI_LINKSTACK_INIT(var) { \
var = NULL; \
- _##var##_pool = BLI_mempool_create(sizeof(LinkNode), 1, 64, 0); \
+ _##var##_pool = BLI_mempool_create(sizeof(LinkNode), 1, 64, BLI_MEMPOOL_NOP); \
} (void)0
#define BLI_LINKSTACK_SIZE(var) \
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h
index 3fab77f..25694f4 100644
--- a/source/blender/blenlib/BLI_mempool.h
+++ b/source/blender/blenlib/BLI_mempool.h
@@ -81,8 +81,8 @@ typedef struct BLI_mempool_iter {
/* flag */
enum {
- BLI_MEMPOOL_SYSMALLOC = (1 << 0),
- BLI_MEMPOOL_ALLOW_ITER = (1 << 1)
+ BLI_MEMPOOL_NOP = 0,
+ BLI_MEMPOOL_ALLOW_ITER = (1 << 0),
};
void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL();
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index f3ebddd..169b98d 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -191,7 +191,7 @@ static GHash *ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info,
}
gh->buckets = MEM_callocN(gh->nbuckets * sizeof(*gh->buckets), "buckets");
- gh->entrypool = BLI_mempool_create(entry_size, 64, 64, 0);
+ gh->entrypool = BLI_mempool_create(entry_size, 64, 64, BLI_MEMPOOL_NOP);
return gh;
}
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 04a1b75..e4cff4c 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -140,21 +140,10 @@ static BLI_mempool_chunk *mempool_chunk_alloc(BLI_mempool *pool)
{
BLI_mempool_chunk *mpchunk;
#ifdef USE_DATA_PTR
- if (pool->flag & BLI_MEMPOOL_SYSMALLOC) {
- mpchunk = malloc(sizeof(BLI_mempool_chunk));
- CHUNK_DATA(mpchunk) = malloc((size_t)pool->csize);
- }
- else {
- mpchunk = MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk");
- CHUNK_DATA(mpchunk) = MEM_mallocN((size_t)pool->csize, "BLI Mempool Chunk Data");
- }
+ mpchunk = MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk");
+ CHUNK_DATA(mpchunk) = MEM_mallocN((size_t)pool->csize, "BLI Mempool Chunk Data");
#else
- if (pool->flag & BLI_MEMPOOL_SYSMALLOC) {
- mpchunk = malloc(sizeof(BLI_mempool_chunk) + (size_t)pool->csize);
- }
- else {
- mpchunk = MEM_mallocN(sizeof(BLI_mempool_chunk) + (size_t)pool->csize, "BLI_Mempool Chunk");
- }
+ mpchunk = MEM_mallocN(sizeof(BLI_mempool_chunk) + (size_t)pool->csize, "BLI_Mempool Chunk");
#endif
return mpchunk;
@@ -219,29 +208,22 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool, BLI_mempool_chunk *mpc
return curnode;
}
-static void mempool_chunk_free(BLI_mempool_chunk *mpchunk, const unsigned int flag)
+static void mempool_chunk_free(BLI_mempool_chunk *mpchunk)
{
- if (flag & BLI_MEMPOOL_SYSMALLOC) {
-#ifdef USE_DATA_PTR
- free(CHUNK_DATA(mpchunk));
-#endif
- free(mpchunk);
- }
- else {
+
#ifdef USE_DATA_PTR
- MEM_freeN(CHUNK_DATA(mpchunk));
+ MEM_freeN(CHUNK_DATA(mpchunk));
#endif
- MEM_freeN(mpchunk);
- }
+ MEM_freeN(mpchunk);
}
-static void mempool_chunk_free_all(BLI_mempool_chunk *mpchunk, const unsigned int flag)
+static void mempool_chunk_free_all(BLI_mempool_chunk *mpchunk)
{
BLI_mempool_chunk *mpchunk_next;
for (; mpchunk; mpchunk = mpchunk_next) {
mpchunk_next = mpchunk->next;
- mempool_chunk_free(mpchunk, flag);
+ mempool_chunk_free(mpchunk);
}
}
@@ -253,12 +235,7 @@ BLI_mempool *BLI_mempool_create(unsigned int esize, unsigned int totelem,
unsigned int i, maxchunks;
/* allocate the pool structure */
- if (flag & BLI_MEMPOOL_SYSMALLOC) {
- pool = malloc(sizeof(BLI_mempool));
- }
- else {
- pool = MEM_mallocN(sizeof(BLI_mempool), "memory pool");
- }
+ pool = MEM_mallocN(sizeof(BLI_mempool), "memory pool");
/* set the elem size */
if (esize < (int)MEMPOOL_ELEM_SIZE_MIN) {
@@ -387,7 +364,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
BLI_mempool_chunk *first;
first = pool->chunks;
- mempool_chunk_free_all(first->next, pool->flag);
+ mempool_chunk_free_all(first->next);
first->next = NULL;
#ifdef USE_TOTALLOC
@@ -602,7 +579,7 @@ void BLI_mempool_clear_ex(BLI_mempool *pool, const int totelem_reserve)
do {
mpchunk_next = mpchunk->next;
- mempool_chunk_free(mpchunk, pool->flag);
+ mempool_chunk_free(mpchunk);
} while ((mpchunk = mpchunk_next));
}
@@ -635,18 +612,13 @@ void BLI_mempool_clear(BLI_mempool *pool)
*/
void BLI_mempool_destroy(BLI_mempool *pool)
{
- mempool_chunk_free_all(pool->chunks, pool->flag);
+ mempool_chunk_free_all(pool->chunks);
#ifdef WITH_MEM_VALGRIND
VALGRIND_DESTROY_MEMPOOL(pool);
#endif
- if (pool->flag & BLI_MEMPOOL_SYSMALLOC) {
- free(pool);
- }
- else {
- MEM_freeN(pool);
- }
+ MEM_freeN(pool);
}
#ifndef NDEBUG
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index c12efbd..c191d8b 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -190,7 +190,7 @@ static EdgeHash *edgehash_new(const char *info,
}
eh->buckets = MEM_callocN(eh->nbuckets * sizeof(*eh->buckets), "eh buckets");
- eh->epool = BLI_mempool_create(entry_size, 512, 512, BLI_MEMPOOL_SYSMALLOC);
+ eh->epool = BLI_mempool_create(entry_size, 512, 512, BLI_MEMPOOL_NOP);
return eh;
}
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c
index 4c91f22..bedb9c5 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.c
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.c
@@ -298,7 +298,7 @@ bool BM_mesh_edgeloops_find_path(BMesh *bm, ListBase *r_eloops,
BMVert *v_match[2] = {NULL, NULL};
ListBase lb_src = {NULL, NULL};
ListBase lb_dst = {NULL, NULL};
- BLI_mempool *vs_pool = BLI_mempool_create(sizeof(struct VertStep), 1, 512, 0);
+ BLI_mempool *vs_pool = BLI_mempool_create(sizeof(struct VertStep), 1, 512, BLI_MEMPOOL_NOP);
/* edge args are dummy */
vs_add(vs_pool, &lb_src, v_src, v_src->e, 1);
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index dc8e85b..372252d 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -373,8 +373,8 @@ static BMLogEntry *bm_log_entry_create(void)
entry->added_faces = BLI_ghash_ptr_new(__func__);
entry->modified_verts = BLI_ghash_ptr_new(__func__);
- entry->pool_verts = BLI_mempool_create(sizeof(BMLogVert), 1, 64, 0);
- entry->pool_faces = BLI_mempool_create(sizeof(BMLogFace), 1, 64, 0);
+ entry->pool_verts = BLI_mempool_create(sizeof(BMLogVert), 1, 64, BLI_MEMPOOL_NOP);
+ entry->pool_faces = BLI_mempool_create(sizeof(BMLogFace), 1, 64, BLI_MEMPOOL_NOP);
return entry;
}
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 66326a4..ec01f13 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -52,12 +52,12 @@ static void bm_mempool_init(BMesh *bm, const BMAllocTemplate *allocsize)
bm->epool = BLI_mempool_create(sizeof(BMEdge), allocsize->totedge,
bm_mesh_chunksize_default.totedge, BLI_MEMPOOL_ALLOW_ITER);
bm->lpool = BLI_mempool_create(sizeof(BMLoop), allocsize->totloop,
- bm_mesh_chunksize_default.totloop, 0);
+ bm_mesh_chunksize_default.totloop, BLI_MEMPOOL_NOP);
bm->fpool = BLI_mempool_create(sizeof(BMFace), allocsize->totface,
bm_mesh_chunksize_default.totface, BLI_MEMPOOL_ALLOW_ITER);
#ifdef USE_BMESH_HOLES
- bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), 512, 512, 0);
+ bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), 512, 512, BLI_MEMPOOL_NOP);
#endif
}
@@ -67,9 +67,9 @@ void BM_mesh_elem_toolflags_ensure(BMesh *bm)
return;
}
- bm->vtoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), max_ii(512, bm->totvert), 512, 0);
- bm->etoolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), max_ii(512, bm->tote
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list