diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-10-22 17:00:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-10-22 17:00:02 +0400 |
commit | 436bbdfd247f66a856b17e4e73db8f8fb3fe6d6d (patch) | |
tree | c72eb1ce03d701a7a99ab0b039f89b20af28374c /source/blender/blenlib | |
parent | 4e11fe6c5aec1d609e3ecc2218138b838d253ebf (diff) |
style cleanup: use more const's in BLI_heap & dpx/cineon style cleanup
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_utildefines.h | 5 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_heap.c | 17 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdtree.c | 6 |
3 files changed, 13 insertions, 15 deletions
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 0dab51154eb..801cff089d7 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -109,9 +109,7 @@ #define CHECK_TYPE_INLINE(val, type) \ ((void)(((type *)0) != (val))) - -#ifndef SWAP -# define SWAP(type, a, b) { \ +#define SWAP(type, a, b) { \ type sw_ap; \ CHECK_TYPE(a, type); \ CHECK_TYPE(b, type); \ @@ -119,7 +117,6 @@ (a) = (b); \ (b) = sw_ap; \ } (void)0 -#endif /* swap with a temp value */ #define SWAP_TVAL(tval, a, b) { \ diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index 42dca360f4c..dcc028630e2 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -84,10 +84,13 @@ BLI_INLINE void heap_swap(Heap *heap, const unsigned int i, const unsigned int j static void heap_down(Heap *heap, unsigned int i) { + /* size won't change in the loop */ + const unsigned int size = heap->size; + while (1) { - unsigned int size = heap->size,smallest ; - unsigned int l = HEAP_LEFT(i); - unsigned int r = HEAP_RIGHT(i); + const unsigned int l = HEAP_LEFT(i); + const unsigned int r = HEAP_RIGHT(i); + unsigned int smallest; smallest = ((l < size) && HEAP_COMPARE(heap->tree[l], heap->tree[i])) ? l : i; @@ -105,7 +108,7 @@ static void heap_down(Heap *heap, unsigned int i) static void heap_up(Heap *heap, unsigned int i) { while (i > 0) { - unsigned int p = HEAP_PARENT(i); + const unsigned int p = HEAP_PARENT(i); if (HEAP_COMPARE(heap->tree[p], heap->tree[i])) break; @@ -139,9 +142,11 @@ void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp) { unsigned int i; - if (ptrfreefp) - for (i = 0; i < heap->size; i++) + if (ptrfreefp) { + for (i = 0; i < heap->size; i++) { ptrfreefp(heap->tree[i]->ptr); + } + } MEM_freeN(heap->tree); BLI_memarena_free(heap->arena); diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index 900580317f2..dd6c25ab6ad 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -30,16 +30,12 @@ * \ingroup bli */ - - #include "MEM_guardedalloc.h" #include "BLI_math.h" #include "BLI_kdtree.h" +#include "BLI_utildefines.h" -#ifndef SWAP -# define SWAP(type, a, b) { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; } (void)0 -#endif typedef struct KDTreeNode { struct KDTreeNode *left, *right; |