From 07b1608fbe52f729eae39c307060f92948aabf37 Mon Sep 17 00:00:00 2001 From: Geoffrey Bantle Date: Sun, 1 Jun 2008 17:15:03 +0000 Subject: -> New memory allocator for Bmesh Added a new pooling allocator for Bmesh based upon the pool allocator availible in the Boost C++ library as described here: http://www.boost.org/doc/libs/1_34_0/libs/pool/doc/concepts.html Each pool allocates elements of a fixed size, so every element type in a mesh gets its own pool. For instance verts occupy a different pool than edges. Each pool is comprised of multiple arrays of a fixed size and allocating /freeing elements is simple as removing or adding a head to a linked list. Since the list of free elements is interleaved throughout the unused space in the arrays, the overhead for storing the free list is only 1 pointer total per pool. This makes building/destroying bmesh structures much faster and saves quite a bit of memory as well. --- source/blender/blenkernel/intern/bmesh_private.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern/bmesh_private.h') diff --git a/source/blender/blenkernel/intern/bmesh_private.h b/source/blender/blenkernel/intern/bmesh_private.h index ad90398bf66..ed58421ffb7 100644 --- a/source/blender/blenkernel/intern/bmesh_private.h +++ b/source/blender/blenkernel/intern/bmesh_private.h @@ -39,6 +39,15 @@ #include "BKE_bmesh.h" +/*MEMORY MANAGMENT*/ +struct BME_mempool; +typedef struct BME_mempool BME_mempool; + +struct BME_mempool *BME_mempool_create(int esize, int tote, int pchunk); +void BME_mempool_destroy(struct BME_mempool *pool); +void *BME_mempool_alloc(struct BME_mempool *pool); +void BME_mempool_free(struct BME_mempool *pool, void *address); + /*ALLOCATION/DEALLOCATION*/ struct BME_Vert *BME_addvertlist(struct BME_Mesh *bm, struct BME_Vert *example); struct BME_Edge *BME_addedgelist(struct BME_Mesh *bm, struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge *example); @@ -49,7 +58,7 @@ void BME_free_vert(struct BME_Mesh *bm, struct BME_Vert *v); void BME_free_edge(struct BME_Mesh *bm, struct BME_Edge *e); void BME_free_poly(struct BME_Mesh *bm, struct BME_Poly *f); void BME_free_loop(struct BME_Mesh *bm, struct BME_Loop *l); -void BME_delete_loop(struct BME_Mesh *bm, struct BME_Loop *l); +//void BME_delete_loop(struct BME_Mesh *bm, struct BME_Loop *l); /*DOUBLE CIRCULAR LINKED LIST FUNCTIONS*/ void BME_cycle_append(void *h, void *nt); -- cgit v1.2.3