diff options
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_ghash.h | 12 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_args.c | 12 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_ghash.c | 30 |
3 files changed, 24 insertions, 30 deletions
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index dd3f62cd6d3..af2605894e3 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -41,7 +41,7 @@ extern "C" { #endif typedef unsigned int (*GHashHashFP) (const void *key); -typedef int (*GHashCmpFP) (const void *a, const void *b); +typedef bool (*GHashCmpFP) (const void *a, const void *b); typedef void (*GHashKeyFreeFP) (void *key); typedef void (*GHashValFreeFP) (void *val); @@ -120,14 +120,14 @@ BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi) { return !ghi * \{ */ unsigned int BLI_ghashutil_ptrhash(const void *key); -int BLI_ghashutil_ptrcmp(const void *a, const void *b); +bool BLI_ghashutil_ptrcmp(const void *a, const void *b); unsigned int BLI_ghashutil_strhash_n(const char *key, size_t n); #define BLI_ghashutil_strhash(key) ( \ CHECK_TYPE_INLINE(key, char *), \ BLI_ghashutil_strhash_p(key)) unsigned int BLI_ghashutil_strhash_p(const void *key); -int BLI_ghashutil_strcmp(const void *a, const void *b); +bool BLI_ghashutil_strcmp(const void *a, const void *b); #define BLI_ghashutil_inthash(key) ( \ CHECK_TYPE_INLINE(&(key), int *), \ @@ -139,11 +139,11 @@ unsigned int BLI_ghashutil_uinthash(unsigned int key); unsigned int BLI_ghashutil_uinthash_v4(const unsigned int key[4]); #define BLI_ghashutil_inthash_v4_p \ ((GSetHashFP)BLI_ghashutil_uinthash_v4) -int BLI_ghashutil_uinthash_v4_cmp(const void *a, const void *b); +bool BLI_ghashutil_uinthash_v4_cmp(const void *a, const void *b); #define BLI_ghashutil_inthash_v4_cmp \ BLI_ghashutil_uinthash_v4_cmp unsigned int BLI_ghashutil_inthash_p(const void *ptr); -int BLI_ghashutil_intcmp(const void *a, const void *b); +bool BLI_ghashutil_intcmp(const void *a, const void *b); /** \} */ @@ -167,7 +167,7 @@ typedef struct GHashPair { GHashPair *BLI_ghashutil_pairalloc(const void *first, const void *second); unsigned int BLI_ghashutil_pairhash(const void *ptr); -int BLI_ghashutil_paircmp(const void *a, const void *b); +bool BLI_ghashutil_paircmp(const void *a, const void *b); void BLI_ghashutil_pairfree(void *ptr); diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c index 8bd35f651b7..49a3c466727 100644 --- a/source/blender/blenlib/intern/BLI_args.c +++ b/source/blender/blenlib/intern/BLI_args.c @@ -91,15 +91,17 @@ static unsigned int keyhash(const void *ptr) return case_strhash(k->arg); /* ^ BLI_ghashutil_inthash((void *)k->pass); */ } -static int keycmp(const void *a, const void *b) +static bool keycmp(const void *a, const void *b) { const bAKey *ka = a; const bAKey *kb = b; if (ka->pass == kb->pass || ka->pass == -1 || kb->pass == -1) { /* -1 is wildcard for pass */ - if (ka->case_str == 1 || kb->case_str == 1) - return BLI_strcasecmp(ka->arg, kb->arg); - else - return strcmp(ka->arg, kb->arg); + if (ka->case_str == 1 || kb->case_str == 1) { + return (BLI_strcasecmp(ka->arg, kb->arg) != 0); + } + else { + return (strcmp(ka->arg, kb->arg) != 0); + } } else { return BLI_ghashutil_intcmp((const void *)ka->pass, (const void *)kb->pass); diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 74d7fdc88cb..aa17ef393c9 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -683,12 +683,9 @@ unsigned int BLI_ghashutil_ptrhash(const void *key) return (unsigned int)y; } #endif -int BLI_ghashutil_ptrcmp(const void *a, const void *b) +bool BLI_ghashutil_ptrcmp(const void *a, const void *b) { - if (a == b) - return 0; - else - return (a < b) ? -1 : 1; + return (a != b); } unsigned int BLI_ghashutil_uinthash_v4(const unsigned int key[4]) @@ -704,9 +701,9 @@ unsigned int BLI_ghashutil_uinthash_v4(const unsigned int key[4]) return hash; } -int BLI_ghashutil_uinthash_v4_cmp(const void *a, const void *b) +bool BLI_ghashutil_uinthash_v4_cmp(const void *a, const void *b) { - return memcmp(a, b, sizeof(unsigned int[4])); + return (memcmp(a, b, sizeof(unsigned int[4])) != 0); } unsigned int BLI_ghashutil_uinthash(unsigned int key) @@ -735,12 +732,9 @@ unsigned int BLI_ghashutil_inthash_p(const void *ptr) return (unsigned int)(key & 0xffffffff); } -int BLI_ghashutil_intcmp(const void *a, const void *b) +bool BLI_ghashutil_intcmp(const void *a, const void *b) { - if (a == b) - return 0; - else - return (a < b) ? -1 : 1; + return (a != b); } /** @@ -774,9 +768,9 @@ unsigned int BLI_ghashutil_strhash_p(const void *ptr) return h; } -int BLI_ghashutil_strcmp(const void *a, const void *b) +bool BLI_ghashutil_strcmp(const void *a, const void *b) { - return strcmp(a, b); + return (strcmp(a, b) != 0); } GHashPair *BLI_ghashutil_pairalloc(const void *first, const void *second) @@ -794,15 +788,13 @@ unsigned int BLI_ghashutil_pairhash(const void *ptr) return hash ^ BLI_ghashutil_ptrhash(pair->second); } -int BLI_ghashutil_paircmp(const void *a, const void *b) +bool BLI_ghashutil_paircmp(const void *a, const void *b) { const GHashPair *A = a; const GHashPair *B = b; - int cmp = BLI_ghashutil_ptrcmp(A->first, B->first); - if (cmp == 0) - return BLI_ghashutil_ptrcmp(A->second, B->second); - return cmp; + return (BLI_ghashutil_ptrcmp(A->first, B->first) || + BLI_ghashutil_ptrcmp(A->second, B->second)); } void BLI_ghashutil_pairfree(void *ptr) |