[Bf-blender-cvs] [4725994] master: Cleanup: ghash/edgehash style

Campbell Barton noreply at git.blender.org
Sun Nov 29 07:53:12 CET 2015


Commit: 472599402fcf1bc702afcf7729632d1a56770591
Author: Campbell Barton
Date:   Sun Nov 29 16:52:05 2015 +1100
Branches: master
https://developer.blender.org/rB472599402fcf1bc702afcf7729632d1a56770591

Cleanup: ghash/edgehash style

Call functions on own lines (nicer for debugging)

===================================================================

M	source/blender/blenlib/intern/BLI_ghash.c
M	source/blender/blenlib/intern/edgehash.c

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 7e6dabd..a36a762 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 cde4a8b..02b11e7 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;




More information about the Bf-blender-cvs mailing list