diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-11-29 08:52:05 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-11-29 09:51:12 +0300 |
commit | 472599402fcf1bc702afcf7729632d1a56770591 (patch) | |
tree | e6d10442d7bb95ccbccf06ba7f33cefa53aa9c31 | |
parent | 37801588d4b9d919bab40f1fa22d631d31eb2105 (diff) |
Cleanup: ghash/edgehash style
Call functions on own lines (nicer for debugging)
-rw-r--r-- | source/blender/blenlib/intern/BLI_ghash.c | 50 | ||||
-rw-r--r-- | source/blender/blenlib/intern/edgehash.c | 18 |
2 files changed, 50 insertions, 18 deletions
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 7e6dabdffef..a36a762a0e1 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -487,7 +487,8 @@ BLI_INLINE void ghash_insert(GHash *gh, void *key, void *val) } BLI_INLINE bool ghash_insert_safe( - GHash *gh, void *key, void *val, const bool override, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) + GHash *gh, void *key, void *val, const bool override, + GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) { const unsigned int hash = ghash_keyhash(gh, key); const unsigned int bucket_index = ghash_bucket_index(gh, hash); @@ -497,8 +498,12 @@ BLI_INLINE bool ghash_insert_safe( if (e) { if (override) { - if (keyfreefp) keyfreefp(e->e.key); - if (valfreefp) valfreefp(e->val); + if (keyfreefp) { + keyfreefp(e->e.key); + } + if (valfreefp) { + valfreefp(e->val); + } e->e.key = key; e->val = val; } @@ -510,7 +515,9 @@ BLI_INLINE bool ghash_insert_safe( } } -BLI_INLINE bool ghash_insert_safe_keyonly(GHash *gh, void *key, const bool override, GHashKeyFreeFP keyfreefp) +BLI_INLINE bool ghash_insert_safe_keyonly( + GHash *gh, void *key, const bool override, + GHashKeyFreeFP keyfreefp) { const unsigned int hash = ghash_keyhash(gh, key); const unsigned int bucket_index = ghash_bucket_index(gh, hash); @@ -520,7 +527,9 @@ BLI_INLINE bool ghash_insert_safe_keyonly(GHash *gh, void *key, const bool overr if (e) { if (override) { - if (keyfreefp) keyfreefp(e->key); + if (keyfreefp) { + keyfreefp(e->key); + } e->key = key; } return false; @@ -535,7 +544,8 @@ BLI_INLINE bool ghash_insert_safe_keyonly(GHash *gh, void *key, const bool overr * Remove the entry and return it, caller must free from gh->entrypool. */ static Entry *ghash_remove_ex( - GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp, + GHash *gh, const void *key, + GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp, const unsigned int bucket_index) { Entry *e_prev; @@ -544,11 +554,19 @@ static Entry *ghash_remove_ex( BLI_assert(!valfreefp || !(gh->flag & GHASH_FLAG_IS_GSET)); if (e) { - if (keyfreefp) keyfreefp(e->key); - if (valfreefp) valfreefp(((GHashEntry *)e)->val); + if (keyfreefp) { + keyfreefp(e->key); + } + if (valfreefp) { + valfreefp(((GHashEntry *)e)->val); + } - if (e_prev) e_prev->next = e->next; - else gh->buckets[bucket_index] = e->next; + if (e_prev) { + e_prev->next = e->next; + } + else { + gh->buckets[bucket_index] = e->next; + } ghash_buckets_contract(gh, --gh->nentries, false, false); } @@ -559,7 +577,9 @@ static Entry *ghash_remove_ex( /** * Run free callbacks for freeing entries. */ -static void ghash_free_cb(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) +static void ghash_free_cb( + GHash *gh, + GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) { unsigned int i; @@ -570,8 +590,12 @@ static void ghash_free_cb(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP va Entry *e; for (e = gh->buckets[i]; e; e = e->next) { - if (keyfreefp) keyfreefp(e->key); - if (valfreefp) valfreefp(((GHashEntry *)e)->val); + if (keyfreefp) { + keyfreefp(e->key); + } + if (valfreefp) { + valfreefp(((GHashEntry *)e)->val); + } } } } diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c index cde4a8bf59d..02b11e7b8ee 100644 --- a/source/blender/blenlib/intern/edgehash.c +++ b/source/blender/blenlib/intern/edgehash.c @@ -283,8 +283,10 @@ BLI_INLINE void edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, /** * Remove the entry and return it, caller must free from eh->epool. */ -static EdgeEntry *edgehash_remove_ex(EdgeHash *eh, unsigned int v0, unsigned int v1, EdgeHashFreeFP valfreefp, - unsigned int hash) +static EdgeEntry *edgehash_remove_ex( + EdgeHash *eh, unsigned int v0, unsigned int v1, + EdgeHashFreeFP valfreefp, + unsigned int hash) { EdgeEntry *e; EdgeEntry *e_prev = NULL; @@ -295,10 +297,16 @@ static EdgeEntry *edgehash_remove_ex(EdgeHash *eh, unsigned int v0, unsigned int if (UNLIKELY(v0 == e->v0 && v1 == e->v1)) { EdgeEntry *e_next = e->next; - if (valfreefp) valfreefp(e->val); + if (valfreefp) { + valfreefp(e->val); + } - if (e_prev) e_prev->next = e_next; - else eh->buckets[hash] = e_next; + if (e_prev) { + e_prev->next = e_next; + } + else { + eh->buckets[hash] = e_next; + } eh->nentries--; return e; |