diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-20 02:36:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-20 02:36:24 +0400 |
commit | 1cad189e32708d4f9cc5b0a649d4c07f1e1c3eff (patch) | |
tree | fcbb86e55042b96c99bf0e4bc54670910cc111e5 /source/blender/blenlib/intern/scanfill.c | |
parent | a368e6771a5f707f41f5959c345943cad07ef7e8 (diff) |
fix harmless but annoying memory leak prints, "newmem", now free all scanfill memory on exit.
Diffstat (limited to 'source/blender/blenlib/intern/scanfill.c')
-rw-r--r-- | source/blender/blenlib/intern/scanfill.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 64beed24fc5..1e25d74cfb6 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -143,7 +143,7 @@ struct mem_elements { free in the end, with argument '-1' */ #define MEM_ELEM_BLOCKSIZE 16384 -static struct mem_elements * melem__cur= 0; +static struct mem_elements * melem__cur= NULL; static int melem__offs= 0; /* the current free address */ static ListBase melem__lb= {NULL, NULL}; @@ -167,13 +167,14 @@ static void *mem_element_new(int size) return melem__cur->data; } } -static void mem_element_reset(void) +static void mem_element_reset(int keep_first) { struct mem_elements *first; - /*BMESH_TODO: keep the first block, gives memory leak on exit with 'newmem' */ if((first= melem__lb.first)) { /* can be false if first fill fails */ - BLI_remlink(&melem__lb, first); + if (keep_first) { + BLI_remlink(&melem__lb, first); + } melem__cur= melem__lb.first; while(melem__cur) { @@ -183,8 +184,14 @@ static void mem_element_reset(void) BLI_freelistN(&melem__lb); /*reset the block we're keeping*/ - BLI_addtail(&melem__lb, first); - memset(first->data, 0, MEM_ELEM_BLOCKSIZE); + if (keep_first) { + BLI_addtail(&melem__lb, first); + memset(first->data, 0, MEM_ELEM_BLOCKSIZE); + } + else { + first = NULL; + + } } melem__cur= first; @@ -193,7 +200,7 @@ static void mem_element_reset(void) void BLI_end_edgefill(void) { - mem_element_reset(); + mem_element_reset(TRUE); fillvertbase.first= fillvertbase.last= 0; filledgebase.first= filledgebase.last= 0; @@ -202,6 +209,11 @@ void BLI_end_edgefill(void) BLI_unlock_thread(LOCK_SCANFILL); } +void BLI_scanfill_free(void) +{ + mem_element_reset(FALSE); +} + /* **** FILL ROUTINES *************************** */ ScanFillVert *BLI_addfillvert(const float vec[3]) |