Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-08-04 07:00:04 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-08-04 07:00:04 +0400
commitbd89bd9e1c49369d9d08bf262602a7520cec7123 (patch)
treef0d3fe425cc057df4c0db2efe5571970060deb31 /intern/guardedalloc/MEM_guardedalloc.h
parent5881fe5d679b38eb40b59c1af3bc3db88a53f35d (diff)
avoid using MEM_reallocN_id directly, add utility macro for freeing.
Diffstat (limited to 'intern/guardedalloc/MEM_guardedalloc.h')
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h22
1 files changed, 7 insertions, 15 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 764340beb71..d46d7ad67bc 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -102,25 +102,12 @@ extern "C" {
#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
* as a system realloc but just makes a new allocation and copies
* over from existing memory. */
- void *MEM_reallocN(void *vmemh, size_t len)
+ void *MEM_reallocN_id(void *vmemh, size_t len, const char *str)
#if MEM_GNU_ATTRIBUTES
__attribute__((warn_unused_result))
__attribute__((alloc_size(2)))
@@ -130,13 +117,16 @@ extern "C" {
/**
* A variant of realloc which zeros new bytes
*/
- void *MEM_recallocN(void *vmemh, size_t len)
+ 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
;
+#define MEM_reallocN(vmemh, len) MEM_reallocN_id(vmemh, len, __func__)
+#define MEM_recallocN(vmemh, len) MEM_recallocN_id(vmemh, len, __func__)
+
/**
* Allocate a block of memory of size len, with tag name str. The
* memory is cleared. The name must be static, because only a
@@ -223,6 +213,8 @@ extern "C" {
#endif
;
+#define MEM_SAFE_FREE(v) if (v) { MEM_freeN(v); v = NULL; } (void)0
+
#ifndef NDEBUG
const char *MEM_name_ptr(void *vmemh);
#endif