[Bf-blender-cvs] [074929d1c5f] master: MEM_guardedalloc: allow freeing const arrays with MEM_SAFE_FREE

Campbell Barton noreply at git.blender.org
Wed Jun 24 14:15:38 CEST 2020


Commit: 074929d1c5f5b0e9a4da3c3058cc9f3038fb2910
Author: Campbell Barton
Date:   Wed Jun 24 22:08:49 2020 +1000
Branches: master
https://developer.blender.org/rB074929d1c5f5b0e9a4da3c3058cc9f3038fb2910

MEM_guardedalloc: allow freeing const arrays with MEM_SAFE_FREE

'const' arrays couldn't use this macro with GNUC.

===================================================================

M	intern/guardedalloc/MEM_guardedalloc.h

===================================================================

diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 602297576c8..bbba69edf1d 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -187,7 +187,8 @@ extern size_t (*MEM_get_peak_memory)(void) ATTR_WARN_UNUSED_RESULT;
     do { \
       typeof(&(v)) _v = &(v); \
       if (*_v) { \
-        MEM_freeN(*_v); \
+        /* Cast so we can free constant arrays. */ \
+        MEM_freeN((void *)*_v); \
         *_v = NULL; \
       } \
     } while (0)



More information about the Bf-blender-cvs mailing list