From 737cb8cf7c6e52ed7eef159b06df247be7d3406f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Jul 2014 18:56:13 +1000 Subject: Use compiler attributes for more BLI libs --- source/blender/blenlib/BLI_dynstr.h | 2 +- source/blender/blenlib/BLI_heap.h | 22 +++++++++++----------- source/blender/blenlib/BLI_rand.h | 32 ++++++++++++++++---------------- 3 files changed, 28 insertions(+), 28 deletions(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_dynstr.h b/source/blender/blenlib/BLI_dynstr.h index 484cddd0039..7aa1c30e449 100644 --- a/source/blender/blenlib/BLI_dynstr.h +++ b/source/blender/blenlib/BLI_dynstr.h @@ -54,7 +54,7 @@ void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len) ATT void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format, ...) ATTR_PRINTF_FORMAT(2, 3) ATTR_NONNULL(1, 2); void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, va_list args) ATTR_PRINTF_FORMAT(2, 0) ATTR_NONNULL(1, 2); -int BLI_dynstr_get_len(DynStr *ds) ATTR_NONNULL(); +int BLI_dynstr_get_len(DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); char *BLI_dynstr_get_cstring(DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); void BLI_dynstr_get_cstring_ex(DynStr *__restrict ds, char *__restrict str) ATTR_NONNULL(); diff --git a/source/blender/blenlib/BLI_heap.h b/source/blender/blenlib/BLI_heap.h index 8a157f5e8db..ac9edfd46a2 100644 --- a/source/blender/blenlib/BLI_heap.h +++ b/source/blender/blenlib/BLI_heap.h @@ -35,31 +35,31 @@ typedef void (*HeapFreeFP)(void *ptr); /* Creates a new heap. BLI_memarena is used for allocating nodes. Removed nodes * are recycled, so memory usage will not shrink. */ -Heap *BLI_heap_new_ex(unsigned int tot_reserve); -Heap *BLI_heap_new(void); -void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp); +Heap *BLI_heap_new_ex(unsigned int tot_reserve) ATTR_WARN_UNUSED_RESULT; +Heap *BLI_heap_new(void) ATTR_WARN_UNUSED_RESULT; +void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp) ATTR_NONNULL(1); /* Insert heap node with a value (often a 'cost') and pointer into the heap, * duplicate values are allowed. */ -HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr); +HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr) ATTR_NONNULL(1); /* Remove a heap node. */ -void BLI_heap_remove(Heap *heap, HeapNode *node); +void BLI_heap_remove(Heap *heap, HeapNode *node) ATTR_NONNULL(1, 2); /* Return 0 if the heap is empty, 1 otherwise. */ -bool BLI_heap_is_empty(Heap *heap); +bool BLI_heap_is_empty(Heap *heap) ATTR_NONNULL(1); /* Return the size of the heap. */ -unsigned int BLI_heap_size(Heap *heap); +unsigned int BLI_heap_size(Heap *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /* Return the top node of the heap. This is the node with the lowest value. */ -HeapNode *BLI_heap_top(Heap *heap); +HeapNode *BLI_heap_top(Heap *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /* Pop the top node off the heap and return it's pointer. */ -void *BLI_heap_popmin(Heap *heap); +void *BLI_heap_popmin(Heap *heap) ATTR_NONNULL(1); /* Return the value or pointer of a heap node. */ -float BLI_heap_node_value(HeapNode *heap); -void *BLI_heap_node_ptr(HeapNode *heap); +float BLI_heap_node_value(HeapNode *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +void *BLI_heap_node_ptr(HeapNode *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); #endif /* __BLI_HEAP_H__ */ diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h index 50ab50e449a..c86b3aea503 100644 --- a/source/blender/blenlib/BLI_rand.h +++ b/source/blender/blenlib/BLI_rand.h @@ -42,33 +42,33 @@ typedef struct RNG RNG; struct RNG *BLI_rng_new(unsigned int seed); struct RNG *BLI_rng_new_srandom(unsigned int seed); -void BLI_rng_free(struct RNG *rng); +void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1); -void BLI_rng_seed(struct RNG *rng, unsigned int seed); -void BLI_rng_srandom(struct RNG *rng, unsigned int seed); -int BLI_rng_get_int(struct RNG *rng); -unsigned int BLI_rng_get_uint(struct RNG *rng); -double BLI_rng_get_double(struct RNG *rng); -float BLI_rng_get_float(struct RNG *rng); -void BLI_rng_get_float_unit_v2(struct RNG *rng, float v[2]); -void BLI_rng_get_float_unit_v3(struct RNG *rng, float v[3]); -void BLI_rng_shuffle_array(struct RNG *rng, void *data, unsigned int elem_size_i, unsigned int elem_tot); +void BLI_rng_seed(struct RNG *rng, unsigned int seed) ATTR_NONNULL(1); +void BLI_rng_srandom(struct RNG *rng, unsigned int seed) ATTR_NONNULL(1); +int BLI_rng_get_int(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +unsigned int BLI_rng_get_uint(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +double BLI_rng_get_double(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +void BLI_rng_get_float_unit_v2(struct RNG *rng, float v[2]) ATTR_NONNULL(1, 2); +void BLI_rng_get_float_unit_v3(struct RNG *rng, float v[3]) ATTR_NONNULL(1, 2); +void BLI_rng_shuffle_array(struct RNG *rng, void *data, unsigned int elem_size_i, unsigned int elem_tot) ATTR_NONNULL(1, 2); /** Note that skipping is as slow as generating n numbers! */ -void BLI_rng_skip(struct RNG *rng, int n); +void BLI_rng_skip(struct RNG *rng, int n) ATTR_NONNULL(1); /** Seed for the random number generator, using noise.c hash[] */ void BLI_srandom(unsigned int seed); /** Return a pseudo-random number N where 0<=N<(2^31) */ -int BLI_rand(void); +int BLI_rand(void) ATTR_WARN_UNUSED_RESULT; /** Return a pseudo-random number N where 0.0f<=N<1.0f */ -float BLI_frand(void); +float BLI_frand(void) ATTR_WARN_UNUSED_RESULT; void BLI_frand_unit_v3(float v[3]); /** Return a pseudo-random (hash) float from an integer value */ -float BLI_hash_frand(unsigned int seed); +float BLI_hash_frand(unsigned int seed) ATTR_WARN_UNUSED_RESULT; /** Shuffle an array randomly using the given seed. * contents. This routine does not use nor modify @@ -83,10 +83,10 @@ void BLI_thread_srandom(int thread, unsigned int seed); /** Return a pseudo-random number N where 0<=N<(2^31) */ /** Allows up to BLENDER_MAX_THREADS threads to address */ -int BLI_thread_rand(int thread); +int BLI_thread_rand(int thread) ATTR_WARN_UNUSED_RESULT; /** Return a pseudo-random number N where 0.0f<=N<1.0f */ /** Allows up to BLENDER_MAX_THREADS threads to address */ -float BLI_thread_frand(int thread); +float BLI_thread_frand(int thread) ATTR_WARN_UNUSED_RESULT; #endif /* __BLI_RAND_H__ */ -- cgit v1.2.3