forked from bartvdbraak/blender
use alloc_size attribute for guarded alloc functions with gcc.
This commit is contained in:
parent
2c8db87897
commit
1d29ee0d3b
@ -71,6 +71,14 @@
|
|||||||
# endif
|
# endif
|
||||||
#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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -101,23 +109,23 @@ extern "C" {
|
|||||||
* allocated block, the old one is freed. this is not as optimized
|
* allocated block, the old one is freed. this is not as optimized
|
||||||
* as a system realloc but just makes a new allocation and copies
|
* as a system realloc but just makes a new allocation and copies
|
||||||
* over from existing memory. */
|
* 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
|
* Allocate a block of memory of size len, with tag name str. The
|
||||||
* memory is cleared. The name must be static, because only a
|
* memory is cleared. The name must be static, because only a
|
||||||
* pointer to it is stored ! */
|
* 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
|
/** 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 !
|
* 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.
|
/** Same as callocN, clears memory and uses mmap (disk cached) if supported.
|
||||||
* Can be free'd with MEM_freeN as usual.
|
* 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
|
/** Print a list of the names and sizes of all allocated memory
|
||||||
* blocks. as a python dict for easy investigation */
|
* blocks. as a python dict for easy investigation */
|
||||||
|
Loading…
Reference in New Issue
Block a user