From 4ab524a66b2fff87f002f58b46f21a06b34b5f96 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Mon, 22 Sep 2025 10:31:30 +0100 Subject: [PATCH] core: hash: rename b_hash_string to avoid conflict with b_string --- core/hash/hash.c | 6 +++--- core/include/blue/core/hash.h | 4 ++-- core/include/blue/core/rope.h | 4 ++-- core/rope.c | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/hash/hash.c b/core/hash/hash.c index b0a3da9..a9f6353 100644 --- a/core/hash/hash.c +++ b/core/hash/hash.c @@ -41,13 +41,13 @@ static const struct b_hash_function_ops *hash_functions[] = { static const size_t nr_hash_functions = sizeof hash_functions / sizeof hash_functions[0]; -uint64_t b_hash_string(const char *s) +uint64_t b_hash_cstr(const char *s) { size_t x = 0; - return b_hash_string_ex(s, &x); + return b_hash_cstr_ex(s, &x); } -uint64_t b_hash_string_ex(const char *s, size_t *len) +uint64_t b_hash_cstr_ex(const char *s, size_t *len) { uint64_t hash = FNV1_OFFSET_BASIS; size_t i = 0; diff --git a/core/include/blue/core/hash.h b/core/include/blue/core/hash.h index e43452c..f309369 100644 --- a/core/include/blue/core/hash.h +++ b/core/include/blue/core/hash.h @@ -97,8 +97,8 @@ typedef struct b_hash_ctx { } ctx_state; } b_hash_ctx; -BLUE_API uint64_t b_hash_string(const char *s); -BLUE_API uint64_t b_hash_string_ex(const char *s, size_t *len); +BLUE_API uint64_t b_hash_cstr(const char *s); +BLUE_API uint64_t b_hash_cstr_ex(const char *s, size_t *len); BLUE_API b_status b_hash_ctx_init(b_hash_ctx *ctx, b_hash_function func); BLUE_API b_status b_hash_ctx_reset(b_hash_ctx *ctx); diff --git a/core/include/blue/core/rope.h b/core/include/blue/core/rope.h index dd3666d..dd1632d 100644 --- a/core/include/blue/core/rope.h +++ b/core/include/blue/core/rope.h @@ -24,7 +24,7 @@ struct b_string; .r_v = { \ .v_cstr = { \ .s = (str), \ - .hash = b_hash_string(str), \ + .hash = b_hash_cstr(str), \ }, \ }, \ } @@ -36,7 +36,7 @@ struct b_string; .r_v = { \ .v_cstr = { \ .s = (str), \ - .hash = b_hash_string(str), \ + .hash = b_hash_cstr(str), \ }, \ }, \ } diff --git a/core/rope.c b/core/rope.c index ad146d6..ecab2ae 100644 --- a/core/rope.c +++ b/core/rope.c @@ -16,7 +16,7 @@ void b_rope_init_cstr(struct b_rope *rope, const char *s) { memset(rope, 0x0, sizeof *rope); rope->r_flags = B_ROPE_F_CSTR; - rope->r_v.v_cstr.hash = b_hash_string_ex(s, &rope->r_len_total); + rope->r_v.v_cstr.hash = b_hash_cstr_ex(s, &rope->r_len_total); rope->r_len_left = rope->r_len_total; char *s2 = malloc(rope->r_len_total + 1); @@ -36,7 +36,7 @@ void b_rope_init_cstr_borrowed(struct b_rope *rope, const char *s) memset(rope, 0x0, sizeof *rope); rope->r_flags = B_ROPE_F_CSTR_BORROWED; rope->r_v.v_cstr.s = s; - rope->r_v.v_cstr.hash = b_hash_string_ex(s, &rope->r_len_total); + rope->r_v.v_cstr.hash = b_hash_cstr_ex(s, &rope->r_len_total); rope->r_len_left = rope->r_len_total; } @@ -45,7 +45,7 @@ void b_rope_init_cstr_static(struct b_rope *rope, const char *s) memset(rope, 0x0, sizeof *rope); rope->r_flags = B_ROPE_F_CSTR_STATIC; rope->r_v.v_cstr.s = s; - rope->r_v.v_cstr.hash = b_hash_string_ex(s, &rope->r_len_total); + rope->r_v.v_cstr.hash = b_hash_cstr_ex(s, &rope->r_len_total); rope->r_len_left = rope->r_len_total; }