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>2012-07-08 07:15:37 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-08 07:15:37 +0400
commit1d29ee0d3b020e574a490951b99a0ba7a17dc72c (patch)
tree989878a26bf49628492bad7c44695c1eaa94bc50 /intern/guardedalloc
parent2c8db878974a340e14b59a6ed5a61fb195ccc67c (diff)
use alloc_size attribute for guarded alloc functions with gcc.
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 4bb8cba6810..c2ec4a3ec4d 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -71,6 +71,14 @@
# endif
#endif
+#ifndef ALLOC_SIZE
+# ifdef __GNUC__
+# define ALLOC_SIZE(arg_pos) __attribute__((alloc_size(arg_pos)))
+# else
+# define ALLOC_SIZE(arg_pos)
+# endif
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -101,23 +109,23 @@ extern "C" {
* 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) WARN_UNUSED;
+ void *MEM_reallocN(void *vmemh, size_t len) WARN_UNUSED ALLOC_SIZE(2);
/**
* Allocate a block of memory of size len, with tag name str. The
* memory is cleared. The name must be static, because only a
* pointer to it is stored ! */
- void *MEM_callocN(size_t len, const char * str) WARN_UNUSED;
+ void *MEM_callocN(size_t len, const char * str) WARN_UNUSED ALLOC_SIZE(1);
/** Allocate a block of memory of size len, with tag name str. The
* name must be a static, because only a pointer to it is stored !
* */
- void *MEM_mallocN(size_t len, const char * str) WARN_UNUSED;
+ void *MEM_mallocN(size_t len, const char * str) WARN_UNUSED ALLOC_SIZE(1);
/** Same as callocN, clears memory and uses mmap (disk cached) if supported.
* Can be free'd with MEM_freeN as usual.
* */
- void *MEM_mapallocN(size_t len, const char * str) WARN_UNUSED;
+ void *MEM_mapallocN(size_t len, const char * str) WARN_UNUSED ALLOC_SIZE(1);
/** Print a list of the names and sizes of all allocated memory
* blocks. as a python dict for easy investigation */