[Bf-blender-cvs] [d4aaa4f] master: cleanup: use const for smallhash & minor edits

Campbell Barton noreply at git.blender.org
Thu Dec 18 13:12:43 CET 2014


Commit: d4aaa4f9b661cd2423a4745227b9883f5f1f4089
Author: Campbell Barton
Date:   Thu Dec 18 13:12:25 2014 +0100
Branches: master
https://developer.blender.org/rBd4aaa4f9b661cd2423a4745227b9883f5f1f4089

cleanup: use const for smallhash & minor edits

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

M	source/blender/blenlib/BLI_smallhash.h
M	source/blender/blenlib/intern/edgehash.c
M	source/blender/blenlib/intern/smallhash.c
M	source/blender/editors/space_image/image_ops.c

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

diff --git a/source/blender/blenlib/BLI_smallhash.h b/source/blender/blenlib/BLI_smallhash.h
index 5bc40a6..e096354 100644
--- a/source/blender/blenlib/BLI_smallhash.h
+++ b/source/blender/blenlib/BLI_smallhash.h
@@ -52,7 +52,7 @@ typedef struct SmallHash {
 } SmallHash;
 
 typedef struct {
-	SmallHash *sh;
+	const SmallHash *sh;
 	unsigned int i;
 } SmallHashIter;
 
@@ -63,14 +63,14 @@ void    BLI_smallhash_release(SmallHash *sh) ATTR_NONNULL(1);
 void    BLI_smallhash_insert(SmallHash *sh, uintptr_t key, void *item) ATTR_NONNULL(1);
 bool    BLI_smallhash_reinsert(SmallHash *sh, uintptr_t key, void *item) ATTR_NONNULL(1);
 bool    BLI_smallhash_remove(SmallHash *sh, uintptr_t key) ATTR_NONNULL(1);
-void   *BLI_smallhash_lookup(SmallHash *sh, uintptr_t key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
-void  **BLI_smallhash_lookup_p(SmallHash *sh, uintptr_t key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
-bool    BLI_smallhash_haskey(SmallHash *sh, uintptr_t key) ATTR_NONNULL(1);
-int     BLI_smallhash_count(SmallHash *sh)  ATTR_NONNULL(1);
+void   *BLI_smallhash_lookup(const SmallHash *sh, uintptr_t key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
+void  **BLI_smallhash_lookup_p(const SmallHash *sh, uintptr_t key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
+bool    BLI_smallhash_haskey(const SmallHash *sh, uintptr_t key) ATTR_NONNULL(1);
+int     BLI_smallhash_count(const SmallHash *sh)  ATTR_NONNULL(1);
 void   *BLI_smallhash_iternext(SmallHashIter *iter, uintptr_t *key)  ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
 void  **BLI_smallhash_iternext_p(SmallHashIter *iter, uintptr_t *key)  ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
-void   *BLI_smallhash_iternew(SmallHash *sh, SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
-void  **BLI_smallhash_iternew_p(SmallHash *sh, SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
+void   *BLI_smallhash_iternew(const SmallHash *sh, SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
+void  **BLI_smallhash_iternew_p(const SmallHash *sh, SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
 /* void BLI_smallhash_print(SmallHash *sh); */ /* UNUSED */
 
 #ifdef DEBUG
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index 8dd7240..82d57da 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -24,7 +24,7 @@
  *  \ingroup bli
  *
  * An (edge -> pointer) chaining hash table.
- * Using unordered int-paits as keys.
+ * Using unordered int-pairs as keys.
  *
  * \note Based on 'BLI_ghash.c', which is a more generalized hash-table
  * make sure these stay in sync.
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index bb91f48..ba336ab 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -118,7 +118,7 @@ BLI_INLINE void smallhash_buckets_reserve(SmallHash *sh, const unsigned int nent
 	}
 }
 
-BLI_INLINE SmallHashEntry *smallhash_lookup(SmallHash *sh, const uintptr_t key)
+BLI_INLINE SmallHashEntry *smallhash_lookup(const SmallHash *sh, const uintptr_t key)
 {
 	SmallHashEntry *e;
 	unsigned int h = smallhash_key(key);
@@ -284,28 +284,28 @@ bool BLI_smallhash_remove(SmallHash *sh, uintptr_t key)
 }
 #endif
 
-void *BLI_smallhash_lookup(SmallHash *sh, uintptr_t key)
+void *BLI_smallhash_lookup(const SmallHash *sh, uintptr_t key)
 {
 	SmallHashEntry *e = smallhash_lookup(sh, key);
 
 	return e ? e->val : NULL;
 }
 
-void **BLI_smallhash_lookup_p(SmallHash *sh, uintptr_t key)
+void **BLI_smallhash_lookup_p(const SmallHash *sh, uintptr_t key)
 {
 	SmallHashEntry *e = smallhash_lookup(sh, key);
 
 	return e ? &e->val : NULL;
 }
 
-bool BLI_smallhash_haskey(SmallHash *sh, uintptr_t key)
+bool BLI_smallhash_haskey(const SmallHash *sh, uintptr_t key)
 {
 	SmallHashEntry *e = smallhash_lookup(sh, key);
 
 	return (e != NULL);
 }
 
-int BLI_smallhash_count(SmallHash *sh)
+int BLI_smallhash_count(const SmallHash *sh)
 {
 	return (int)sh->nentries;
 }
@@ -341,7 +341,7 @@ void **BLI_smallhash_iternext_p(SmallHashIter *iter, uintptr_t *key)
 	return e ? &e->val : NULL;
 }
 
-void *BLI_smallhash_iternew(SmallHash *sh, SmallHashIter *iter, uintptr_t *key)
+void *BLI_smallhash_iternew(const SmallHash *sh, SmallHashIter *iter, uintptr_t *key)
 {
 	iter->sh = sh;
 	iter->i = 0;
@@ -349,7 +349,7 @@ void *BLI_smallhash_iternew(SmallHash *sh, SmallHashIter *iter, uintptr_t *key)
 	return BLI_smallhash_iternext(iter, key);
 }
 
-void **BLI_smallhash_iternew_p(SmallHash *sh, SmallHashIter *iter, uintptr_t *key)
+void **BLI_smallhash_iternew_p(const SmallHash *sh, SmallHashIter *iter, uintptr_t *key)
 {
 	iter->sh = sh;
 	iter->i = 0;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 8445da8..ec90217 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -3125,7 +3125,7 @@ static int render_border_exec(bContext *C, wmOperator *op)
 	}
 
 	rd = RE_engine_get_render_data(re);
-	if ((rd->mode & (R_BORDER|R_CROP)) == (R_BORDER|R_CROP)) {
+	if ((rd->mode & (R_BORDER | R_CROP)) == (R_BORDER | R_CROP)) {
 		BKE_report(op->reports, RPT_INFO, "Can not set border from a cropped render");
 		return OPERATOR_CANCELLED;
 	}




More information about the Bf-blender-cvs mailing list