diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-03 22:05:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-03 22:05:30 +0400 |
commit | da5b04a0c214dffd46b180afa9cd553ff839e13c (patch) | |
tree | 982f003c295ddd97a1e647cde415d92b12d9ad29 /source/blender/blenkernel/intern/pbvh.c | |
parent | 2a8d76d7342b0064284075bb5b88d964eda32e87 (diff) |
fix for over-allocation in BKE_pbvh_search_gather, BKE_pbvh_gather_proxies,
each element was having the size of PBVHNode allocated rather then the size of a pointer (8 vs 184 bytes here)
Diffstat (limited to 'source/blender/blenkernel/intern/pbvh.c')
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index a0cc37dcf3f..9290ccc8c5d 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -753,7 +753,7 @@ void BKE_pbvh_search_gather(PBVH *bvh, PBVHNode ***r_array, int *r_tot) { PBVHIter iter; - PBVHNode **array = NULL, **newarray, *node; + PBVHNode **array = NULL, *node; int tot = 0, space = 0; pbvh_iter_begin(&iter, bvh, scb, search_data); @@ -763,14 +763,7 @@ void BKE_pbvh_search_gather(PBVH *bvh, if (tot == space) { /* resize array if needed */ space = (tot == 0) ? 32 : space * 2; - newarray = MEM_callocN(sizeof(PBVHNode) * space, "PBVHNodeSearch"); - - if (array) { - memcpy(newarray, array, sizeof(PBVHNode) * tot); - MEM_freeN(array); - } - - array = newarray; + array = MEM_recallocN_id(array, sizeof(PBVHNode *) * space, __func__); } array[tot] = node; @@ -1807,7 +1800,7 @@ void BKE_pbvh_node_free_proxies(PBVHNode *node) void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***r_array, int *r_tot) { - PBVHNode **array = NULL, **newarray, *node; + PBVHNode **array = NULL, *node; int tot = 0, space = 0; int n; @@ -1818,14 +1811,7 @@ void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***r_array, int *r_tot) if (tot == space) { /* resize array if needed */ space = (tot == 0) ? 32 : space * 2; - newarray = MEM_callocN(sizeof(PBVHNode) * space, "BKE_pbvh_gather_proxies"); - - if (array) { - memcpy(newarray, array, sizeof(PBVHNode) * tot); - MEM_freeN(array); - } - - array = newarray; + array = MEM_recallocN_id(array, sizeof(PBVHNode *) * space, __func__); } array[tot] = node; |