diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-14 23:40:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-14 23:40:42 +0400 |
commit | a2a594fb3686921e3225a470bc96f61bc12287a8 (patch) | |
tree | 881cb18084b3c3528e6cef158c439ce218576e2c /source/blender | |
parent | 7626101dc9749a3c6066a0f51720d9953b8b3c69 (diff) |
BLI_linklist_free() was incorrectly taking MEM_freeN() as an argument, evidentially this works on x86 - but could cause issues later on.
add BLI_linklist_freeN() which MEM_freeN's each item.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/BLI_linklist.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_linklist.c | 12 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_memarena.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 2 |
4 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_linklist.h b/source/blender/blenlib/BLI_linklist.h index da56a300b9b..3e7fdc8bf75 100644 --- a/source/blender/blenlib/BLI_linklist.h +++ b/source/blender/blenlib/BLI_linklist.h @@ -59,6 +59,7 @@ void BLI_linklist_prepend_arena(struct LinkNode **listp, void *ptr, struct Me void BLI_linklist_insert_after(struct LinkNode **listp, void *ptr); void BLI_linklist_free(struct LinkNode *list, LinkNodeFreeFP freefunc); +void BLI_linklist_freeN(struct LinkNode *list); void BLI_linklist_apply(struct LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata); #endif diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c index 0e630efc349..b08fbe17a43 100644 --- a/source/blender/blenlib/intern/BLI_linklist.c +++ b/source/blender/blenlib/intern/BLI_linklist.c @@ -155,6 +155,18 @@ void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc) } } +void BLI_linklist_freeN(LinkNode *list) +{ + while (list) { + LinkNode *next = list->next; + + MEM_freeN(list->link); + MEM_freeN(list); + + list = next; + } +} + void BLI_linklist_apply(LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata) { for (; list; list = list->next) diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c index 0ac6209fc95..b6b5b600ab1 100644 --- a/source/blender/blenlib/intern/BLI_memarena.c +++ b/source/blender/blenlib/intern/BLI_memarena.c @@ -74,7 +74,7 @@ void BLI_memarena_use_align(struct MemArena *ma, const int align) void BLI_memarena_free(MemArena *ma) { - BLI_linklist_free(ma->bufs, (void (*)(void *))MEM_freeN); + BLI_linklist_freeN(ma->bufs); MEM_freeN(ma); } diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index d09d5744ac6..71cd5e529a2 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -616,7 +616,7 @@ LinkNode *BLI_file_read_as_lines(const char *name) */ void BLI_file_free_lines(LinkNode *lines) { - BLI_linklist_free(lines, (void (*)(void *))MEM_freeN); + BLI_linklist_freeN(lines); } /** is file1 older then file2 */ |