Revision: 58868
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58868
Author:   campbellbarton
Date:     2013-08-03 17:53:41 +0000 (Sat, 03 Aug 2013)
Log Message:
-----------
add versions of MEM_reallocN, MEM_recallocN which take a string arg so new 
allocs have an ID, changing existing functions signatures would be too 
disruptive at the moment.

Modified Paths:
--------------
    trunk/blender/intern/guardedalloc/MEM_guardedalloc.h
    trunk/blender/intern/guardedalloc/intern/mallocn.c
    trunk/blender/source/blender/blenkernel/intern/fmodifier.c
    trunk/blender/source/blender/makesrna/intern/rna_gpencil.c

Modified: trunk/blender/intern/guardedalloc/MEM_guardedalloc.h
===================================================================
--- trunk/blender/intern/guardedalloc/MEM_guardedalloc.h        2013-08-03 
17:29:53 UTC (rev 58867)
+++ trunk/blender/intern/guardedalloc/MEM_guardedalloc.h        2013-08-03 
17:53:41 UTC (rev 58868)
@@ -102,6 +102,19 @@
 #endif
        ;
 
+       void *MEM_reallocN_id(void *vmemh, size_t len, const char *str)
+#if MEM_GNU_ATTRIBUTES
+       __attribute__((warn_unused_result))
+       __attribute__((alloc_size(2)))
+#endif
+       ;
+       void *MEM_recallocN_id(void *vmemh, size_t len, const char *str)
+#if MEM_GNU_ATTRIBUTES
+       __attribute__((warn_unused_result))
+       __attribute__((alloc_size(2)))
+#endif
+       ;
+
        /**
         * Reallocates a block of memory, and returns pointer to the newly
         * allocated block, the old one is freed. this is not as optimized

Modified: trunk/blender/intern/guardedalloc/intern/mallocn.c
===================================================================
--- trunk/blender/intern/guardedalloc/intern/mallocn.c  2013-08-03 17:29:53 UTC 
(rev 58867)
+++ trunk/blender/intern/guardedalloc/intern/mallocn.c  2013-08-03 17:53:41 UTC 
(rev 58868)
@@ -371,7 +371,7 @@
        return newp;
 }
 
-void *MEM_reallocN(void *vmemh, size_t len)
+void *MEM_reallocN_id(void *vmemh, size_t len, const char *str)
 {
        void *newp = NULL;
        
@@ -394,13 +394,13 @@
                MEM_freeN(vmemh);
        }
        else {
-               newp = MEM_mallocN(len, __func__);
+               newp = MEM_mallocN(len, str);
        }
 
        return newp;
 }
 
-void *MEM_recallocN(void *vmemh, size_t len)
+void *MEM_recallocN_id(void *vmemh, size_t len, const char *str)
 {
        void *newp = NULL;
 
@@ -428,12 +428,23 @@
                MEM_freeN(vmemh);
        }
        else {
-               newp = MEM_callocN(len, __func__);
+               newp = MEM_callocN(len, str);
        }
 
        return newp;
 }
 
+
+void *MEM_reallocN(void *vmemh, size_t len)
+{
+       return MEM_reallocN_id(vmemh, len, __func__);
+}
+void *MEM_recallocN(void *vmemh, size_t len)
+{
+       return MEM_recallocN_id(vmemh, len, __func__);
+}
+
+
 #ifdef DEBUG_BACKTRACE
 #  if defined(__linux__) || defined(__APPLE__)
 static void make_memhead_backtrace(MemHead *memh)

Modified: trunk/blender/source/blender/blenkernel/intern/fmodifier.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fmodifier.c  2013-08-03 
17:29:53 UTC (rev 58867)
+++ trunk/blender/source/blender/blenkernel/intern/fmodifier.c  2013-08-03 
17:53:41 UTC (rev 58868)
@@ -144,12 +144,9 @@
                        const int arraysize_new = data->poly_order + 1;
                        /* arraysize needs to be order+1, so resize if not */
                        if (data->arraysize != arraysize_new) {
-                               if (data->coefficients) {
-                                       data->coefficients = 
MEM_recallocN(data->coefficients, sizeof(float) * arraysize_new);
-                               }
-                               else {
-                                       data->coefficients = 
MEM_callocN(sizeof(float) * arraysize_new, "FMod_Generator_Coefs");
-                               }
+                               data->coefficients = 
MEM_recallocN_id(data->coefficients,
+                                                                     
sizeof(float) * arraysize_new,
+                                                                     
"FMod_Generator_Coefs");
                                data->arraysize = arraysize_new;
                        }
                        break;
@@ -159,12 +156,9 @@
                        const int arraysize_new = data->poly_order * 2;
                        /* arraysize needs to be (2 * order), so resize if not 
*/
                        if (data->arraysize != arraysize_new) {
-                               if (data->coefficients) {
-                                       data->coefficients = 
MEM_recallocN(data->coefficients, sizeof(float) * arraysize_new);
-                               }
-                               else {
-                                       data->coefficients = 
MEM_callocN(sizeof(float) * arraysize_new, "FMod_Generator_Coefs");
-                               }
+                               data->coefficients = 
MEM_recallocN_id(data->coefficients,
+                                                                     
sizeof(float) * arraysize_new,
+                                                                     
"FMod_Generator_Coefs");
                                data->arraysize = arraysize_new;
                        }
                        break;

Modified: trunk/blender/source/blender/makesrna/intern/rna_gpencil.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_gpencil.c  2013-08-03 
17:29:53 UTC (rev 58867)
+++ trunk/blender/source/blender/makesrna/intern/rna_gpencil.c  2013-08-03 
17:53:41 UTC (rev 58868)
@@ -118,11 +118,9 @@
 static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count)
 {
        if (count > 0) {
-               if (stroke->points == NULL)
-                       stroke->points = MEM_callocN(sizeof(bGPDspoint) * 
count, "gp_stroke_points");
-               else
-                       stroke->points = MEM_recallocN(stroke->points, 
sizeof(bGPDspoint) * (stroke->totpoints + count));
-
+               stroke->points = MEM_recallocN_id(stroke->points,
+                                                 sizeof(bGPDspoint) * 
(stroke->totpoints + count),
+                                                 "gp_stroke_points");
                stroke->totpoints += count;
        }
 }

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

Reply via email to