Revision: 44818
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44818
Author:   campbellbarton
Date:     2012-03-11 23:47:41 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
style cleanup

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/BLI_ghash.c
    trunk/blender/source/blender/blenlib/intern/BLI_heap.c
    trunk/blender/source/blender/blenlib/intern/BLI_memarena.c
    trunk/blender/source/blender/blenlib/intern/BLI_mempool.c
    trunk/blender/source/blender/blenlib/intern/bpath.c
    trunk/blender/source/blender/blenlib/intern/string_cursor_utf8.c
    trunk/blender/source/blender/blenlib/intern/uvproject.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c

Modified: trunk/blender/source/blender/blenlib/intern/BLI_ghash.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/BLI_ghash.c     2012-03-11 
21:47:14 UTC (rev 44817)
+++ trunk/blender/source/blender/blenlib/intern/BLI_ghash.c     2012-03-11 
23:47:41 UTC (rev 44818)
@@ -33,11 +33,8 @@
 #include <string.h>
 #include <stdlib.h>
 
-
 #include "MEM_guardedalloc.h"
 
-
-
 // #include "BLI_blenlib.h"
 
 #include "BLI_utildefines.h"
@@ -47,7 +44,7 @@
 #include "BLO_sys_types.h" // for intptr_t support
 /***/
 
-unsigned int hashsizes[]= {
+unsigned int hashsizes[] = {
        5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 
        16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, 
        4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 
@@ -58,18 +55,18 @@
 
 GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info)
 {
-       GHash *gh= MEM_mallocN(sizeof(*gh), info);
-       gh->hashfp= hashfp;
-       gh->cmpfp= cmpfp;
+       GHash *gh = MEM_mallocN(sizeof(*gh), info);
+       gh->hashfp = hashfp;
+       gh->cmpfp = cmpfp;
        gh->entrypool = BLI_mempool_create(sizeof(Entry), 64, 64, 0);
 
-       gh->cursize= 0;
-       gh->nentries= 0;
-       gh->nbuckets= hashsizes[gh->cursize];
-       
-       gh->buckets= MEM_mallocN(gh->nbuckets*sizeof(*gh->buckets), "buckets");
-       memset(gh->buckets, 0, gh->nbuckets*sizeof(*gh->buckets));
-       
+       gh->cursize = 0;
+       gh->nentries = 0;
+       gh->nbuckets = hashsizes[gh->cursize];
+
+       gh->buckets = MEM_mallocN(gh->nbuckets * sizeof(*gh->buckets), 
"buckets");
+       memset(gh->buckets, 0, gh->nbuckets * sizeof(*gh->buckets));
+
        return gh;
 }
 
@@ -80,31 +77,31 @@
 
 void BLI_ghash_insert(GHash *gh, void *key, void *val)
 {
-       unsigned int hash= gh->hashfp(key)%gh->nbuckets;
-       Entry *e= (Entry*) BLI_mempool_alloc(gh->entrypool);
+       unsigned int hash = gh->hashfp(key) % gh->nbuckets;
+       Entry *e = (Entry*)BLI_mempool_alloc(gh->entrypool);
 
-       e->key= key;
-       e->val= val;
-       e->next= gh->buckets[hash];
-       gh->buckets[hash]= e;
+       e->key = key;
+       e->val = val;
+       e->next = gh->buckets[hash];
+       gh->buckets[hash] = e;
 
-       if (++gh->nentries>(float)gh->nbuckets/2) {
-               Entry **old= gh->buckets;
-               int i, nold= gh->nbuckets;
+       if (++gh->nentries > (float)gh->nbuckets / 2) {
+               Entry **old = gh->buckets;
+               int i, nold = gh->nbuckets;
 
-               gh->nbuckets= hashsizes[++gh->cursize];
-               gh->buckets= 
(Entry**)MEM_mallocN(gh->nbuckets*sizeof(*gh->buckets), "buckets");
-               memset(gh->buckets, 0, gh->nbuckets*sizeof(*gh->buckets));
+               gh->nbuckets = hashsizes[++gh->cursize];
+               gh->buckets = (Entry**)MEM_mallocN(gh->nbuckets * 
sizeof(*gh->buckets), "buckets");
+               memset(gh->buckets, 0, gh->nbuckets * sizeof(*gh->buckets));
 
-               for (i=0; i<nold; i++) {
-                       for (e= old[i]; e;) {
-                               Entry *n= e->next;
+               for (i = 0; i < nold; i++) {
+                       for (e = old[i]; e;) {
+                               Entry *n = e->next;
 
-                               hash= gh->hashfp(e->key)%gh->nbuckets;
-                               e->next= gh->buckets[hash];
-                               gh->buckets[hash]= e;
+                               hash = gh->hashfp(e->key) % gh->nbuckets;
+                               e->next = gh->buckets[hash];
+                               gh->buckets[hash] = e;
 
-                               e= n;
+                               e = n;
                        }
                }
 
@@ -114,33 +111,35 @@
 
 void *BLI_ghash_lookup(GHash *gh, const void *key)
 {
-       if(gh) {
-               unsigned int hash= gh->hashfp(key)%gh->nbuckets;
+       if (gh) {
+               unsigned int hash = gh->hashfp(key) % gh->nbuckets;
                Entry *e;
 
-               for (e= gh->buckets[hash]; e; e= e->next)
-                       if (gh->cmpfp(key, e->key)==0)
+               for (e = gh->buckets[hash]; e; e = e->next)
+                       if (gh->cmpfp(key, e->key) == 0)
                                return e->val;
        }
        return NULL;
 }
 
-int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, 
GHashValFreeFP valfreefp)
+int BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, 
GHashValFreeFP valfreefp)
 {
-       unsigned int hash= gh->hashfp(key)%gh->nbuckets;
+       unsigned int hash = gh->hashfp(key) % gh->nbuckets;
        Entry *e;
        Entry *p = NULL;
 
-       for (e= gh->buckets[hash]; e; e= e->next) {
-               if (gh->cmpfp(key, e->key)==0) {
-                       Entry *n= e->next;
+       for (e = gh->buckets[hash]; e; e = e->next) {
+               if (gh->cmpfp(key, e->key) == 0) {
+                       Entry *n = e->next;
 
-                       if (keyfreefp) keyfreefp(e->key);
-                       if (valfreefp) valfreefp(e->val);
+                       if (keyfreefp)
+                               keyfreefp(e->key);
+                       if (valfreefp)
+                               valfreefp(e->val);
                        BLI_mempool_free(gh->entrypool, e);
 
                        /* correct but 'e' isnt used before return */
-                       /* e= n; */ /*UNUSED*/
+                       /* e= n; *//*UNUSED*/
                        if (p)
                                p->next = n;
                        else
@@ -157,11 +156,11 @@
 
 int BLI_ghash_haskey(GHash *gh, void *key)
 {
-       unsigned int hash= gh->hashfp(key)%gh->nbuckets;
+       unsigned int hash = gh->hashfp(key) % gh->nbuckets;
        Entry *e;
 
-       for (e= gh->buckets[hash]; e; e= e->next)
-               if (gh->cmpfp(key, e->key)==0)
+       for (e = gh->buckets[hash]; e; e = e->next)
+               if (gh->cmpfp(key, e->key) == 0)
                        return 1;
 
        return 0;
@@ -170,22 +169,22 @@
 void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP 
valfreefp)
 {
        int i;
-       
+
        if (keyfreefp || valfreefp) {
-               for (i=0; i<gh->nbuckets; i++) {
+               for (i = 0; i < gh->nbuckets; i++) {
                        Entry *e;
-                       
-                       for (e= gh->buckets[i]; e; ) {
-                               Entry *n= e->next;
-                               
+
+                       for (e = gh->buckets[i]; e;) {
+                               Entry *n = e->next;
+
                                if (keyfreefp) keyfreefp(e->key);
                                if (valfreefp) valfreefp(e->val);
 
-                               e= n;
+                               e = n;
                        }
                }
        }
-       
+
        MEM_freeN(gh->buckets);
        BLI_mempool_destroy(gh->entrypool);
        gh->buckets = NULL;
@@ -198,28 +197,28 @@
 
 GHashIterator *BLI_ghashIterator_new(GHash *gh)
 {
-       GHashIterator *ghi= MEM_mallocN(sizeof(*ghi), "ghash iterator");
-       ghi->gh= gh;
-       ghi->curEntry= NULL;
-       ghi->curBucket= -1;
+       GHashIterator *ghi = MEM_mallocN(sizeof(*ghi), "ghash iterator");
+       ghi->gh = gh;
+       ghi->curEntry = NULL;
+       ghi->curBucket = -1;
        while (!ghi->curEntry) {
                ghi->curBucket++;
-               if (ghi->curBucket==ghi->gh->nbuckets)
+               if (ghi->curBucket == ghi->gh->nbuckets)
                        break;
-               ghi->curEntry= ghi->gh->buckets[ghi->curBucket];
+               ghi->curEntry = ghi->gh->buckets[ghi->curBucket];
        }
        return ghi;
 }
 void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
 {
-       ghi->gh= gh;
-       ghi->curEntry= NULL;
-       ghi->curBucket= -1;
+       ghi->gh = gh;
+       ghi->curEntry = NULL;
+       ghi->curBucket = -1;
        while (!ghi->curEntry) {
                ghi->curBucket++;
-               if (ghi->curBucket==ghi->gh->nbuckets)
+               if (ghi->curBucket == ghi->gh->nbuckets)
                        break;
-               ghi->curEntry= ghi->gh->buckets[ghi->curBucket];
+               ghi->curEntry = ghi->gh->buckets[ghi->curBucket];
        }
 }
 void BLI_ghashIterator_free(GHashIterator *ghi)
@@ -229,22 +228,22 @@
 
 void *BLI_ghashIterator_getKey(GHashIterator *ghi)
 {
-       return ghi->curEntry?ghi->curEntry->key:NULL;
+       return ghi->curEntry ? ghi->curEntry->key : NULL;
 }
 void *BLI_ghashIterator_getValue(GHashIterator *ghi)
 {
-       return ghi->curEntry?ghi->curEntry->val:NULL;
+       return ghi->curEntry ? ghi->curEntry->val : NULL;
 }
 
 void BLI_ghashIterator_step(GHashIterator *ghi)
 {
        if (ghi->curEntry) {
-               ghi->curEntry= ghi->curEntry->next;
+               ghi->curEntry = ghi->curEntry->next;
                while (!ghi->curEntry) {
                        ghi->curBucket++;
-                       if (ghi->curBucket==ghi->gh->nbuckets)
+                       if (ghi->curBucket == ghi->gh->nbuckets)
                                break;
-                       ghi->curEntry= ghi->gh->buckets[ghi->curBucket];
+                       ghi->curEntry = ghi->gh->buckets[ghi->curBucket];
                }
        }
 }
@@ -261,10 +260,10 @@
 }
 int BLI_ghashutil_ptrcmp(const void *a, const void *b)
 {
-       if (a==b)
+       if (a == b)
                return 0;
        else
-               return (a<b)?-1:1;
+               return (a < b) ? -1 : 1;
 }
 
 unsigned int BLI_ghashutil_inthash(const void *ptr)
@@ -283,21 +282,22 @@
 
 int BLI_ghashutil_intcmp(const void *a, const void *b)
 {
-       if (a==b)
+       if (a == b)
                return 0;
        else
-               return (a<b)?-1:1;
+               return (a < b) ? -1 : 1;
 }
 
 unsigned int BLI_ghashutil_strhash(const void *ptr)
 {
-       const char *s= ptr;
-       unsigned int i= 0;
+       const char *s = ptr;
+       unsigned int i = 0;
        unsigned char c;
-       
-       while ( (c= *s++) )
-               i= i*37 + c;
-               
+
+       while ((c = *s++)) {
+               i = i * 37 + c;
+       }
+
        return i;
 }
 int BLI_ghashutil_strcmp(const void *a, const void *b)
@@ -326,7 +326,7 @@
        const GHashPair *B = b;
 
        int cmp = BLI_ghashutil_ptrcmp(A->first, B->first);
-       if(cmp == 0)
+       if (cmp == 0)
                return BLI_ghashutil_intcmp(SET_INT_IN_POINTER(A->second), 
SET_INT_IN_POINTER(B->second));
        return cmp;
 }

Modified: trunk/blender/source/blender/blenlib/intern/BLI_heap.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/BLI_heap.c      2012-03-11 
21:47:14 UTC (rev 44817)
+++ trunk/blender/source/blender/blenlib/intern/BLI_heap.c      2012-03-11 
23:47:41 UTC (rev 44818)
@@ -30,7 +30,6 @@
  *  \ingroup bli
  */
 
-
 #include <string.h>
 
 #include "MEM_guardedalloc.h"
@@ -55,26 +54,26 @@
 };
 
 #define SWAP(type, a, b) \
-       { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
-#define HEAP_PARENT(i) ((i-1)>>1)
-#define HEAP_LEFT(i)   ((i<<1)+1)
-#define HEAP_RIGHT(i)  ((i<<1)+2)
+       { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; }
+#define HEAP_PARENT(i) ((i - 1) >> 1)
+#define HEAP_LEFT(i)   ((i << 1) + 1)
+#define HEAP_RIGHT(i)  ((i << 1) + 2)
 #define HEAP_COMPARE(a, b) (a->value < b->value)
 #define HEAP_EQUALS(a, b) (a->value == b->value)
 #define HEAP_SWAP(heap, i, j) \
 {                                                                             \
        SWAP(int, heap->tree[i]->index, heap->tree[j]->index);                  
  \
-       SWAP(HeapNode*, heap->tree[i], heap->tree[j]);                          
  \
+       SWAP(HeapNode *, heap->tree[i], heap->tree[j]);                         
  \
 }
 
 /***/
 
 Heap *BLI_heap_new(void)
 {
-       Heap *heap = (Heap*)MEM_callocN(sizeof(Heap), "BLIHeap");
+       Heap *heap = (Heap *)MEM_callocN(sizeof(Heap), __func__);
        heap->bufsize = 1;
-       heap->tree = (HeapNode**)MEM_mallocN(sizeof(HeapNode*), "BLIHeapTree");
-       heap->arena = BLI_memarena_new(1<<16, "heap arena");
+       heap->tree = (HeapNode **)MEM_mallocN(sizeof(HeapNode *), 
"BLIHeapTree");
+       heap->arena = BLI_memarena_new(1 << 16, "heap arena");
 
        return heap;
 }
@@ -86,7 +85,7 @@
        if (ptrfreefp)
                for (i = 0; i < heap->size; i++)
                        ptrfreefp(heap->tree[i]->ptr);
-       
+
        MEM_freeN(heap->tree);
        BLI_memarena_free(heap->arena);
        MEM_freeN(heap);
@@ -99,11 +98,11 @@
                int l = HEAP_LEFT(i);
                int r = HEAP_RIGHT(i);
 
-               smallest = ((l < size) && HEAP_COMPARE(heap->tree[l], 
heap->tree[i]))? l: i;
+               smallest = ((l < size) && HEAP_COMPARE(heap->tree[l], 
heap->tree[i])) ? l : i;
 
                if ((r < size) && HEAP_COMPARE(heap->tree[r], 
heap->tree[smallest]))
                        smallest = r;
-               
+
                if (smallest == i)
                        break;
 
@@ -130,11 +129,11 @@
        HeapNode *node;
 
        if ((heap->size + 1) > heap->bufsize) {

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to