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-10-22 12:15:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-10-22 12:15:51 +0400
commitddc2dbc2a47ed2439a62e82ad6fba7d8c9dcae28 (patch)
treea7ca593a96652e6f0a784b5c6e37ab2c35b07159 /source/blender/blenlib/intern
parent30fd258a0b407419a369fbb2818c49df6b70968e (diff)
style cleanup
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/BLI_heap.c8
-rw-r--r--source/blender/blenlib/intern/math_rotation.c20
-rw-r--r--source/blender/blenlib/intern/string_utf8.c2
3 files changed, 16 insertions, 14 deletions
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c
index d3b1bdfa8fa..42dca360f4c 100644
--- a/source/blender/blenlib/intern/BLI_heap.c
+++ b/source/blender/blenlib/intern/BLI_heap.c
@@ -122,6 +122,7 @@ static void heap_up(Heap *heap, unsigned int i)
Heap *BLI_heap_new_ex(unsigned int tot_reserve)
{
Heap *heap = (Heap *)MEM_callocN(sizeof(Heap), __func__);
+ /* ensure we have at least one so we can keep doubling it */
heap->bufsize = MAX2(1, tot_reserve);
heap->tree = (HeapNode **)MEM_mallocN(heap->bufsize * sizeof(HeapNode *), "BLIHeapTree");
heap->arena = BLI_memarena_new(1 << 16, "heap arena");
@@ -151,8 +152,8 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr)
{
HeapNode *node;
- if ((heap->size + 1) > heap->bufsize) {
- heap->bufsize = heap->bufsize * 2;
+ if (UNLIKELY((heap->size + 1) > heap->bufsize)) {
+ heap->bufsize *= 2;
heap->tree = MEM_reallocN(heap->tree, heap->bufsize * sizeof(*heap->tree));
}
@@ -199,8 +200,9 @@ void *BLI_heap_popmin(Heap *heap)
heap->tree[0]->ptr = heap->freenodes;
heap->freenodes = heap->tree[0];
- if (heap->size == 1)
+ if (UNLIKELY(heap->size == 1)) {
heap->size--;
+ }
else {
heap_swap(heap, 0, heap->size - 1);
heap->size--;
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index ce13a278274..70d9ef27734 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1679,34 +1679,34 @@ void vec_apply_track(float vec[3], short axis)
switch (axis) {
case 0: /* pos-x */
- /* vec[0]= 0.0; */
+ /* vec[0] = 0.0; */
vec[1] = tvec[2];
vec[2] = -tvec[1];
break;
case 1: /* pos-y */
- /* vec[0]= tvec[0]; */
- /* vec[1]= 0.0; */
- /* vec[2]= tvec[2]; */
+ /* vec[0] = tvec[0]; */
+ /* vec[1] = 0.0; */
+ /* vec[2] = tvec[2]; */
break;
case 2: /* pos-z */
- /* vec[0]= tvec[0]; */
- /* vec[1]= tvec[1]; */
- /* vec[2]= 0.0; */
+ /* vec[0] = tvec[0]; */
+ /* vec[1] = tvec[1]; */
+ /* vec[2] = 0.0; */
break;
case 3: /* neg-x */
- /* vec[0]= 0.0; */
+ /* vec[0] = 0.0; */
vec[1] = tvec[2];
vec[2] = -tvec[1];
break;
case 4: /* neg-y */
vec[0] = -tvec[2];
- /* vec[1]= 0.0; */
+ /* vec[1] = 0.0; */
vec[2] = tvec[0];
break;
case 5: /* neg-z */
vec[0] = -tvec[0];
vec[1] = -tvec[1];
- /* vec[2]= 0.0; */
+ /* vec[2] = 0.0; */
break;
}
}
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index 17b9ed7ea8d..2543a1637b2 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -214,7 +214,7 @@ size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t max
len += BLI_str_utf8_from_unicode(*src++, dst + len);
}
- dst[len]= '\0';
+ dst[len] = '\0';
return len;
}