cleanup: use const for smallhash & minor edits

This commit is contained in:
Campbell Barton 2014-12-18 13:12:25 +01:00
parent c1eec5582a
commit d4aaa4f9b6
4 changed files with 16 additions and 16 deletions

@ -52,7 +52,7 @@ typedef struct SmallHash {
} SmallHash; } SmallHash;
typedef struct { typedef struct {
SmallHash *sh; const SmallHash *sh;
unsigned int i; unsigned int i;
} SmallHashIter; } 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); 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_reinsert(SmallHash *sh, uintptr_t key, void *item) ATTR_NONNULL(1);
bool BLI_smallhash_remove(SmallHash *sh, uintptr_t key) 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(const 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; void **BLI_smallhash_lookup_p(const SmallHash *sh, uintptr_t key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
bool BLI_smallhash_haskey(SmallHash *sh, uintptr_t key) ATTR_NONNULL(1); bool BLI_smallhash_haskey(const SmallHash *sh, uintptr_t key) ATTR_NONNULL(1);
int BLI_smallhash_count(SmallHash *sh) 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(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_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(const 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_p(const SmallHash *sh, SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
/* void BLI_smallhash_print(SmallHash *sh); */ /* UNUSED */ /* void BLI_smallhash_print(SmallHash *sh); */ /* UNUSED */
#ifdef DEBUG #ifdef DEBUG

@ -24,7 +24,7 @@
* \ingroup bli * \ingroup bli
* *
* An (edge -> pointer) chaining hash table. * 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 * \note Based on 'BLI_ghash.c', which is a more generalized hash-table
* make sure these stay in sync. * make sure these stay in sync.

@ -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; SmallHashEntry *e;
unsigned int h = smallhash_key(key); unsigned int h = smallhash_key(key);
@ -284,28 +284,28 @@ bool BLI_smallhash_remove(SmallHash *sh, uintptr_t key)
} }
#endif #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); SmallHashEntry *e = smallhash_lookup(sh, key);
return e ? e->val : NULL; 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); SmallHashEntry *e = smallhash_lookup(sh, key);
return e ? &e->val : NULL; 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); SmallHashEntry *e = smallhash_lookup(sh, key);
return (e != NULL); return (e != NULL);
} }
int BLI_smallhash_count(SmallHash *sh) int BLI_smallhash_count(const SmallHash *sh)
{ {
return (int)sh->nentries; return (int)sh->nentries;
} }
@ -341,7 +341,7 @@ void **BLI_smallhash_iternext_p(SmallHashIter *iter, uintptr_t *key)
return e ? &e->val : NULL; 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->sh = sh;
iter->i = 0; iter->i = 0;
@ -349,7 +349,7 @@ void *BLI_smallhash_iternew(SmallHash *sh, SmallHashIter *iter, uintptr_t *key)
return BLI_smallhash_iternext(iter, 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->sh = sh;
iter->i = 0; iter->i = 0;

@ -3125,7 +3125,7 @@ static int render_border_exec(bContext *C, wmOperator *op)
} }
rd = RE_engine_get_render_data(re); 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"); BKE_report(op->reports, RPT_INFO, "Can not set border from a cropped render");
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }