diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-14 16:47:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-14 16:47:49 +0400 |
commit | 98520ce4deccb24e5992930694bb4189f6fce0f3 (patch) | |
tree | f568145afab15183e27ddbc0b37b19ed5ffcc758 /source | |
parent | ac8c56c6fc9e1a816160144b5cebe2e99ffa67fc (diff) |
use gcc attributes for BLI alloc functions
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_memarena.h | 39 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_mempool.h | 62 |
2 files changed, 84 insertions, 17 deletions
diff --git a/source/blender/blenlib/BLI_memarena.h b/source/blender/blenlib/BLI_memarena.h index abba03ece9d..2a2dd31b26f 100644 --- a/source/blender/blenlib/BLI_memarena.h +++ b/source/blender/blenlib/BLI_memarena.h @@ -50,16 +50,43 @@ extern "C" { struct MemArena; typedef struct MemArena MemArena; +struct MemArena *BLI_memarena_new(const int bufsize, const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull(2))) +#endif +; -struct MemArena *BLI_memarena_new(int bufsize, const char *name); -void BLI_memarena_free(struct MemArena *ma); +void BLI_memarena_free(struct MemArena *ma) +#ifdef __GNUC__ +__attribute__((nonnull(1))) +#endif +; -void BLI_memarena_use_malloc(struct MemArena *ma); -void BLI_memarena_use_calloc(struct MemArena *ma); +void BLI_memarena_use_malloc(struct MemArena *ma) +#ifdef __GNUC__ +__attribute__((nonnull(1))) +#endif +; +void BLI_memarena_use_calloc(struct MemArena *ma) +#ifdef __GNUC__ +__attribute__((nonnull(1))) +#endif +; -void BLI_memarena_use_align(struct MemArena *ma, int align); +void BLI_memarena_use_align(struct MemArena *ma, const int align) +#ifdef __GNUC__ +__attribute__((nonnull(1))) +#endif +; -void *BLI_memarena_alloc(struct MemArena *ma, int size); +void *BLI_memarena_alloc(struct MemArena *ma, int size) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull(1))) +__attribute__((alloc_size(2))) +#endif +; #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h index 9d7c7d496c8..c773cfbe680 100644 --- a/source/blender/blenlib/BLI_mempool.h +++ b/source/blender/blenlib/BLI_mempool.h @@ -48,16 +48,47 @@ typedef struct BLI_mempool BLI_mempool; * first four bytes of the elements never contain the character string * 'free'. use with care.*/ -BLI_mempool *BLI_mempool_create(int esize, int totelem, int pchunk, int flag); -void *BLI_mempool_alloc(BLI_mempool *pool); -void *BLI_mempool_calloc(BLI_mempool *pool); -void BLI_mempool_free(BLI_mempool *pool, void *addr); -void BLI_mempool_destroy(BLI_mempool *pool); -int BLI_mempool_count(BLI_mempool *pool); -void *BLI_mempool_findelem(BLI_mempool *pool, int index); +BLI_mempool *BLI_mempool_create(int esize, int totelem, int pchunk, int flag) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +#endif +; +void *BLI_mempool_alloc(BLI_mempool *pool) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull(1))) +#endif +; +void *BLI_mempool_calloc(BLI_mempool *pool) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull(1))) +#endif +; +void BLI_mempool_free(BLI_mempool *pool, void *addr) +#ifdef __GNUC__ +__attribute__((nonnull(1, 2))) +#endif +; +void BLI_mempool_destroy(BLI_mempool *pool) +#ifdef __GNUC__ +__attribute__((nonnull(1))) +#endif +; +int BLI_mempool_count(BLI_mempool *pool) +#ifdef __GNUC__ +__attribute__((nonnull(1))) +#endif +; +void *BLI_mempool_findelem(BLI_mempool *pool, int index) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull(1))) +#endif +; /** iteration stuff. note: this may easy to produce bugs with **/ -/*private structure*/ +/* private structure */ typedef struct BLI_mempool_iter { BLI_mempool *pool; struct BLI_mempool_chunk *curchunk; @@ -70,11 +101,20 @@ enum { BLI_MEMPOOL_ALLOW_ITER = (1 << 1) }; -void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter); -void *BLI_mempool_iterstep(BLI_mempool_iter *iter); +void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) +#ifdef __GNUC__ +__attribute__((nonnull(1, 2))) +#endif +; +void *BLI_mempool_iterstep(BLI_mempool_iter *iter) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull(1))) +#endif +; #ifdef __cplusplus } #endif -#endif +#endif /* __BLI_MEMPOOL_H__ */ |