Revision: 58869
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58869
Author:   campbellbarton
Date:     2013-08-03 18:05:30 +0000 (Sat, 03 Aug 2013)
Log Message:
-----------
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)

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/pbvh.c

Modified: trunk/blender/source/blender/blenkernel/intern/pbvh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pbvh.c       2013-08-03 
17:53:41 UTC (rev 58868)
+++ trunk/blender/source/blender/blenkernel/intern/pbvh.c       2013-08-03 
18:05:30 UTC (rev 58869)
@@ -753,7 +753,7 @@
                             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 @@
                        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_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 @@
                        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;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to