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)
This commit is contained in:
@@ -753,7 +753,7 @@ void BKE_pbvh_search_gather(PBVH *bvh,
|
|||||||
PBVHNode ***r_array, int *r_tot)
|
PBVHNode ***r_array, int *r_tot)
|
||||||
{
|
{
|
||||||
PBVHIter iter;
|
PBVHIter iter;
|
||||||
PBVHNode **array = NULL, **newarray, *node;
|
PBVHNode **array = NULL, *node;
|
||||||
int tot = 0, space = 0;
|
int tot = 0, space = 0;
|
||||||
|
|
||||||
pbvh_iter_begin(&iter, bvh, scb, search_data);
|
pbvh_iter_begin(&iter, bvh, scb, search_data);
|
||||||
@@ -763,14 +763,7 @@ void BKE_pbvh_search_gather(PBVH *bvh,
|
|||||||
if (tot == space) {
|
if (tot == space) {
|
||||||
/* resize array if needed */
|
/* resize array if needed */
|
||||||
space = (tot == 0) ? 32 : space * 2;
|
space = (tot == 0) ? 32 : space * 2;
|
||||||
newarray = MEM_callocN(sizeof(PBVHNode) * space, "PBVHNodeSearch");
|
array = MEM_recallocN_id(array, sizeof(PBVHNode *) * space, __func__);
|
||||||
|
|
||||||
if (array) {
|
|
||||||
memcpy(newarray, array, sizeof(PBVHNode) * tot);
|
|
||||||
MEM_freeN(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
array = newarray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
array[tot] = node;
|
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)
|
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 tot = 0, space = 0;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@@ -1818,14 +1811,7 @@ void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***r_array, int *r_tot)
|
|||||||
if (tot == space) {
|
if (tot == space) {
|
||||||
/* resize array if needed */
|
/* resize array if needed */
|
||||||
space = (tot == 0) ? 32 : space * 2;
|
space = (tot == 0) ? 32 : space * 2;
|
||||||
newarray = MEM_callocN(sizeof(PBVHNode) * space, "BKE_pbvh_gather_proxies");
|
array = MEM_recallocN_id(array, sizeof(PBVHNode *) * space, __func__);
|
||||||
|
|
||||||
if (array) {
|
|
||||||
memcpy(newarray, array, sizeof(PBVHNode) * tot);
|
|
||||||
MEM_freeN(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
array = newarray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
array[tot] = node;
|
array[tot] = node;
|
||||||
|
Reference in New Issue
Block a user