diff --git a/.clang-format b/.clang-format index 12abbc64b5f..0f55ff7bb65 100644 --- a/.clang-format +++ b/.clang-format @@ -24,4 +24,5 @@ AlignOperands: false Cpp11BracedListStyle: false ForEachMacros: ['rz_list_foreach', 'rz_list_foreach_safe', 'rz_pvector_foreach', 'rz_rbtree_foreach', 'rz_interval_tree_foreach', 'ls_foreach', 'rz_skiplist_foreach', 'graph_foreach_anode'] SortIncludes: false -RequiresClausePosition: SingleLine \ No newline at end of file +RequiresClausePosition: SingleLine +TypenameMacros: ['HT_', 'Ht_', 'HtName_'] \ No newline at end of file diff --git a/librz/arch/dwarf_process.c b/librz/arch/dwarf_process.c index 33a3e78f286..ff5763fd1b4 100644 --- a/librz/arch/dwarf_process.c +++ b/librz/arch/dwarf_process.c @@ -468,7 +468,8 @@ static const char *map_dwarf_reg_to_riscv_reg(ut32 reg_num) { } #define KASE(_num, _reg) \ - case _num: return #_reg; + case _num: \ + return #_reg; #include #include diff --git a/librz/debug/debug.c b/librz/debug/debug.c index 9a4474f3a92..61ca02e6d24 100644 --- a/librz/debug/debug.c +++ b/librz/debug/debug.c @@ -1234,7 +1234,7 @@ RZ_API int rz_debug_continue_kill(RzDebug *dbg, int sig) { #if DEBUGGER /// if the plugin is not compiled link fails, so better do runtime linking /// until this code gets fixed - static bool (*linux_attach_new_process)(RzDebug *dbg, int pid) = NULL; + static bool (*linux_attach_new_process)(RzDebug * dbg, int pid) = NULL; if (!linux_attach_new_process) { linux_attach_new_process = rz_sys_dlsym(NULL, "linux_attach_new_process"); } diff --git a/librz/include/rz_util/ht_inc.h b/librz/include/rz_util/ht_inc.h index 52d6ef190b9..5242e2ec6a1 100644 --- a/librz/include/rz_util/ht_inc.h +++ b/librz/include/rz_util/ht_inc.h @@ -76,9 +76,9 @@ #ifndef HT_STR_OPTION_DEFINED #define HT_STR_OPTION_DEFINED typedef enum { - HT_STR_DUP = 0, ///< String is copied when inserting into HT - HT_STR_OWN, ///< String ownership is transferred when inserting into HT - HT_STR_CONST ///< String is treated as constant and not copied when inserting into HT + HT_STR_DUP = 0, ///< String is copied when inserting into HT + HT_STR_OWN, ///< String ownership is transferred when inserting into HT + HT_STR_CONST ///< String is treated as constant and not copied when inserting into HT } HtStrOption; #endif @@ -105,7 +105,7 @@ typedef int (*HT_(ListComparator))(const KEY_TYPE, const KEY_TYPE); typedef bool (*HT_(ForeachCallback))(void *user, const KEY_TYPE, const VALUE_TYPE); typedef struct Ht_(bucket_t) { - HT_(Kv) * arr; + HT_(Kv) *arr; ut32 count; } HT_(Bucket); @@ -114,31 +114,25 @@ HT_(Bucket); * Options contain all the settings of the hashtable. */ typedef struct Ht_(options_t) { - HT_(ListComparator) - cmp; ///< RZ_NULLABLE. Function for comparing keys. Returns 0 if keys are equal. - ///< Function is invoked only if == operator applied to keys returns false. - HT_(HashFunction) - hashfn; ///< RZ_NULLABLE. Function for hashing items in the hash table. - ///< If NULL KEY_TO_HASH macro is used. - HT_(DupKey) - dupkey; ///< RZ_NULLABLE. Function for making a copy of key. - ///< If NULL simple assignment operator is used. - HT_(DupValue) - dupvalue; ///< RZ_NULLABLE. Function for making a copy of value. - ///< If NULL simple assignment operator is used. - HT_(CalcSizeK) - calcsizeK; ///< RZ_NULLABLE. Function to determine the key's size. - ///< If NULL zero value is used as a size. - ///< Key sizes are checked on equality during keys comparsion as a pre-check. - HT_(CalcSizeV) - calcsizeV; ///< RZ_NULLABLE. Function to determine the value's size. - ///< If NULL zero value is used as a size. - ///< Not required for common scenarios. Could be used in subclasses. - HT_(FiniKv) - finiKV; ///< RZ_NULLABLE. Function to clean up the key-value store. + HT_(ListComparator) cmp; ///< RZ_NULLABLE. Function for comparing keys. + ///< Returns 0 if keys are equal. + ///< Function is invoked only if == operator applied to keys returns false. + HT_(HashFunction) hashfn; ///< RZ_NULLABLE. Function for hashing items in the hash table. + ///< If NULL KEY_TO_HASH macro is used. + HT_(DupKey) dupkey; ///< RZ_NULLABLE. Function for making a copy of key. + ///< If NULL simple assignment operator is used. + HT_(DupValue) dupvalue; ///< RZ_NULLABLE. Function for making a copy of value. + ///< If NULL simple assignment operator is used. + HT_(CalcSizeK) calcsizeK; ///< RZ_NULLABLE. Function to determine the key's size. + ///< If NULL zero value is used as a size. + ///< Key sizes are checked on equality during keys comparsion as a pre-check. + HT_(CalcSizeV) calcsizeV; ///< RZ_NULLABLE. Function to determine the value's size. + ///< If NULL zero value is used as a size. + ///< Not required for common scenarios. Could be used in subclasses. + HT_(FiniKv) finiKV; ///< RZ_NULLABLE. Function to clean up the key-value store. void *finiKV_user; ///< RZ_NULLABLE. User data which is passed into finiKV. size_t elem_size; ///< Size of each HtKv element (useful for subclassing like SdbKv). - ///< Zero value means to use default size of HtKv. + ///< Zero value means to use default size of HtKv. } HT_(Options); @@ -146,34 +140,33 @@ HT_(Options); typedef struct Ht_(t) { ut32 size; ///< Size of the hash table in buckets. ut32 count; ///< Number of stored elements. - HT_(Bucket) * table; ///< Actual table. + HT_(Bucket) *table; ///< Actual table. ut32 prime_idx; - HT_(Options) - opt; + HT_(Options) opt; } HtName_(Ht); // Create a new Ht with the provided Options -RZ_API RZ_OWN HtName_(Ht) * Ht_(new_opt)(RZ_NONNULL HT_(Options) * opt); +RZ_API RZ_OWN HtName_(Ht) *Ht_(new_opt)(RZ_NONNULL HT_(Options) *opt); // Create a new Ht with the provided Options and initial size -RZ_API RZ_OWN HtName_(Ht) * Ht_(new_opt_size)(RZ_NONNULL HT_(Options) * opt, ut32 initial_size); +RZ_API RZ_OWN HtName_(Ht) *Ht_(new_opt_size)(RZ_NONNULL HT_(Options) *opt, ut32 initial_size); // Destroy a hashtable and all of its entries. -RZ_API void Ht_(free)(RZ_NULLABLE HtName_(Ht) * ht); +RZ_API void Ht_(free)(RZ_NULLABLE HtName_(Ht) *ht); // Insert a new Key-Value pair into the hashtable. If the key already exists, returns false. -RZ_API bool Ht_(insert)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, VALUE_TYPE value); +RZ_API bool Ht_(insert)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value); // Insert a new Key-Value pair into the hashtable, or updates the value if the key already exists. -RZ_API bool Ht_(update)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, VALUE_TYPE value); +RZ_API bool Ht_(update)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value); // Update the key of an element in the hashtable -RZ_API bool Ht_(update_key)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE old_key, const KEY_TYPE new_key); +RZ_API bool Ht_(update_key)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE old_key, const KEY_TYPE new_key); // Delete a key from the hashtable. -RZ_API bool Ht_(delete)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key); +RZ_API bool Ht_(delete)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key); // Find the value corresponding to the matching key. -RZ_API VALUE_TYPE Ht_(find)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, RZ_NULLABLE bool *found); +RZ_API VALUE_TYPE Ht_(find)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, RZ_NULLABLE bool *found); // Iterates over all elements in the hashtable, calling the cb function on each Kv. // If the cb returns false, the iteration is stopped. // cb should not modify the hashtable. // NOTE: cb can delete the current element, but it should be avoided -RZ_API void Ht_(foreach)(RZ_NONNULL HtName_(Ht) * ht, RZ_NONNULL HT_(ForeachCallback) cb, RZ_NULLABLE void *user); +RZ_API void Ht_(foreach)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(ForeachCallback) cb, RZ_NULLABLE void *user); -RZ_API RZ_BORROW HT_(Kv) * Ht_(find_kv)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, RZ_NULLABLE bool *found); -RZ_API bool Ht_(insert_kv)(RZ_NONNULL HtName_(Ht) * ht, RZ_NONNULL HT_(Kv) * kv, bool update); +RZ_API RZ_BORROW HT_(Kv) *Ht_(find_kv)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, RZ_NULLABLE bool *found); +RZ_API bool Ht_(insert_kv)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(Kv) *kv, bool update); diff --git a/librz/include/rz_util/ht_sp.h b/librz/include/rz_util/ht_sp.h index 3514c5a66c5..c90e8504718 100644 --- a/librz/include/rz_util/ht_sp.h +++ b/librz/include/rz_util/ht_sp.h @@ -15,7 +15,7 @@ extern "C" { #define HT_TYPE 5 #include -RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(HtStrOption key_opt, RZ_NULLABLE HT_(DupValue) dup_val, RZ_NULLABLE HT_(FreeValue) free_val); +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt, RZ_NULLABLE HT_(DupValue) dup_val, RZ_NULLABLE HT_(FreeValue) free_val); #undef HT_TYPE #ifdef __cplusplus diff --git a/librz/include/rz_util/ht_ss.h b/librz/include/rz_util/ht_ss.h index a9012ad18e7..b659e9e0cc1 100644 --- a/librz/include/rz_util/ht_ss.h +++ b/librz/include/rz_util/ht_ss.h @@ -15,7 +15,7 @@ extern "C" { #define HT_TYPE 6 #include -RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(HtStrOption key_opt, HtStrOption val_opt); +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt, HtStrOption val_opt); #undef HT_TYPE #ifdef __cplusplus diff --git a/librz/include/rz_util/ht_su.h b/librz/include/rz_util/ht_su.h index c5181a2380e..d116a6d06d1 100644 --- a/librz/include/rz_util/ht_su.h +++ b/librz/include/rz_util/ht_su.h @@ -15,7 +15,7 @@ extern "C" { #define HT_TYPE 7 #include -RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(HtStrOption key_opt); +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt); #undef HT_TYPE #ifdef __cplusplus diff --git a/librz/include/rz_util/ht_up.h b/librz/include/rz_util/ht_up.h index 2d55c65b426..5dbc5076f63 100644 --- a/librz/include/rz_util/ht_up.h +++ b/librz/include/rz_util/ht_up.h @@ -17,8 +17,8 @@ extern "C" { #define HT_TYPE 2 #include -RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree); -RZ_API RZ_OWN HtName_(Ht) * Ht_(new_size)(ut32 initial_size, RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree); +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree); +RZ_API RZ_OWN HtName_(Ht) *Ht_(new_size)(ut32 initial_size, RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree); #undef HT_TYPE #ifdef __cplusplus diff --git a/librz/include/rz_util/ht_uu.h b/librz/include/rz_util/ht_uu.h index f73171b2d17..b82c1065f90 100644 --- a/librz/include/rz_util/ht_uu.h +++ b/librz/include/rz_util/ht_uu.h @@ -17,7 +17,7 @@ extern "C" { #define HT_TYPE 3 #include -RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(void); +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(void); #undef HT_TYPE #ifdef __cplusplus diff --git a/librz/util/ht/ht_inc.c b/librz/util/ht/ht_inc.c index 3e96ee3acd3..78e751b00e2 100644 --- a/librz/util/ht/ht_inc.c +++ b/librz/util/ht/ht_inc.c @@ -21,31 +21,31 @@ static const ut32 ht_primes_sizes[] = { 4166287, 4999559, 5999471, 7199369 }; -static inline ut32 hashfn(HtName_(Ht) * ht, const KEY_TYPE k) { +static inline ut32 hashfn(HtName_(Ht) *ht, const KEY_TYPE k) { return ht->opt.hashfn ? ht->opt.hashfn(k) : KEY_TO_HASH(k); } -static inline ut32 bucketfn(HtName_(Ht) * ht, const KEY_TYPE k) { +static inline ut32 bucketfn(HtName_(Ht) *ht, const KEY_TYPE k) { return hashfn(ht, k) % ht->size; } -static inline KEY_TYPE dupkey(HtName_(Ht) * ht, const KEY_TYPE k) { +static inline KEY_TYPE dupkey(HtName_(Ht) *ht, const KEY_TYPE k) { return ht->opt.dupkey ? ht->opt.dupkey(k) : (KEY_TYPE)k; } -static inline VALUE_TYPE dupval(HtName_(Ht) * ht, const VALUE_TYPE v) { +static inline VALUE_TYPE dupval(HtName_(Ht) *ht, const VALUE_TYPE v) { return ht->opt.dupvalue ? ht->opt.dupvalue(v) : (VALUE_TYPE)v; } -static inline ut32 calcsize_key(HtName_(Ht) * ht, const KEY_TYPE k) { +static inline ut32 calcsize_key(HtName_(Ht) *ht, const KEY_TYPE k) { return ht->opt.calcsizeK ? ht->opt.calcsizeK(k) : 0; } -static inline ut32 calcsize_val(HtName_(Ht) * ht, const VALUE_TYPE v) { +static inline ut32 calcsize_val(HtName_(Ht) *ht, const VALUE_TYPE v) { return ht->opt.calcsizeV ? ht->opt.calcsizeV(v) : 0; } -static inline void fini_kv_pair(HtName_(Ht) * ht, HT_(Kv) * kv) { +static inline void fini_kv_pair(HtName_(Ht) *ht, HT_(Kv) *kv) { if (ht->opt.finiKV) { ht->opt.finiKV(kv, ht->opt.finiKV_user); } @@ -64,7 +64,7 @@ static inline ut32 compute_size(ut32 idx, ut32 sz) { return idx != UT32_MAX && idx < S_ARRAY_SIZE(ht_primes_sizes) ? ht_primes_sizes[idx] : (sz | 1); } -static inline bool is_kv_equal(HtName_(Ht) * ht, const KEY_TYPE key, const ut32 key_len, const HT_(Kv) * kv) { +static inline bool is_kv_equal(HtName_(Ht) *ht, const KEY_TYPE key, const ut32 key_len, const HT_(Kv) *kv) { if (key_len != kv->key_len) { return false; } @@ -76,11 +76,11 @@ static inline bool is_kv_equal(HtName_(Ht) * ht, const KEY_TYPE key, const ut32 return res; } -static inline HT_(Kv) * kv_at(HtName_(Ht) * ht, HT_(Bucket) * bt, ut32 i) { +static inline HT_(Kv) *kv_at(HtName_(Ht) *ht, HT_(Bucket) *bt, ut32 i) { return (HT_(Kv) *)((char *)bt->arr + i * ht->opt.elem_size); } -static inline HT_(Kv) * next_kv(HtName_(Ht) * ht, HT_(Kv) * kv) { +static inline HT_(Kv) *next_kv(HtName_(Ht) *ht, HT_(Kv) *kv) { return (HT_(Kv) *)((char *)kv + ht->opt.elem_size); } @@ -96,7 +96,7 @@ static inline HT_(Kv) * next_kv(HtName_(Ht) * ht, HT_(Kv) * kv) { // Create a new hashtable and return a pointer to it. // size - number of buckets in the hashtable -static RZ_OWN HtName_(Ht) * internal_ht_new(ut32 size, ut32 prime_idx, HT_(Options) * opt) { +static RZ_OWN HtName_(Ht) *internal_ht_new(ut32 size, ut32 prime_idx, HT_(Options) *opt) { HtName_(Ht) *ht = RZ_NEW0(HtName_(Ht)); if (!ht) { return NULL; @@ -123,7 +123,7 @@ static RZ_OWN HtName_(Ht) * internal_ht_new(ut32 size, ut32 prime_idx, HT_(Optio * * Options are copied to an inner field. */ -RZ_API RZ_OWN HtName_(Ht) * Ht_(new_opt)(RZ_NONNULL HT_(Options) * opt) { +RZ_API RZ_OWN HtName_(Ht) *Ht_(new_opt)(RZ_NONNULL HT_(Options) *opt) { rz_return_val_if_fail(opt, NULL); return internal_ht_new(ht_primes_sizes[0], 0, opt); } @@ -134,7 +134,7 @@ RZ_API RZ_OWN HtName_(Ht) * Ht_(new_opt)(RZ_NONNULL HT_(Options) * opt) { * * Options are copied to an inner field. */ -RZ_API RZ_OWN HtName_(Ht) * Ht_(new_opt_size)(RZ_NONNULL HT_(Options) * opt, ut32 initial_size) { +RZ_API RZ_OWN HtName_(Ht) *Ht_(new_opt_size)(RZ_NONNULL HT_(Options) *opt, ut32 initial_size) { rz_return_val_if_fail(opt, NULL); ut32 idx = 0; while (idx < S_ARRAY_SIZE(ht_primes_sizes) && @@ -148,7 +148,7 @@ RZ_API RZ_OWN HtName_(Ht) * Ht_(new_opt_size)(RZ_NONNULL HT_(Options) * opt, ut3 return internal_ht_new(sz, idx, opt); } -RZ_API void Ht_(free)(RZ_NULLABLE HtName_(Ht) * ht) { +RZ_API void Ht_(free)(RZ_NULLABLE HtName_(Ht) *ht) { if (!ht) { return; } @@ -156,7 +156,7 @@ RZ_API void Ht_(free)(RZ_NULLABLE HtName_(Ht) * ht) { ut32 i; for (i = 0; i < ht->size; i++) { HT_(Bucket) *bt = &ht->table[i]; - HT_(Kv) * kv; + HT_(Kv) *kv; ut32 j; if (ht->opt.finiKV) { @@ -172,8 +172,8 @@ RZ_API void Ht_(free)(RZ_NULLABLE HtName_(Ht) * ht) { } // Increases the size of the hashtable by 2. -static void internal_ht_grow(HtName_(Ht) * ht) { - HtName_(Ht) * ht2; +static void internal_ht_grow(HtName_(Ht) *ht) { + HtName_(Ht) *ht2; HtName_(Ht) swap; ut32 idx = next_idx(ht->prime_idx); ut32 sz = compute_size(idx, ht->size * 2); @@ -188,7 +188,7 @@ static void internal_ht_grow(HtName_(Ht) * ht) { for (i = 0; i < ht->size; i++) { HT_(Bucket) *bt = &ht->table[i]; - HT_(Kv) * kv; + HT_(Kv) *kv; ut32 j; BUCKET_FOREACH(ht, bt, j, kv) { @@ -204,15 +204,15 @@ static void internal_ht_grow(HtName_(Ht) * ht) { Ht_(free)(ht2); } -static void check_growing(HtName_(Ht) * ht) { +static void check_growing(HtName_(Ht) *ht) { if (ht->count >= LOAD_FACTOR * ht->size) { internal_ht_grow(ht); } } -static HT_(Kv) * reserve_kv(HtName_(Ht) * ht, const KEY_TYPE key, const int key_len, bool update) { +static HT_(Kv) *reserve_kv(HtName_(Ht) *ht, const KEY_TYPE key, const int key_len, bool update) { HT_(Bucket) *bt = &ht->table[bucketfn(ht, key)]; - HT_(Kv) * kvtmp; + HT_(Kv) *kvtmp; ut32 j; BUCKET_FOREACH(ht, bt, j, kvtmp) { @@ -236,7 +236,7 @@ static HT_(Kv) * reserve_kv(HtName_(Ht) * ht, const KEY_TYPE key, const int key_ return kv_at(ht, bt, bt->count - 1); } -RZ_API bool Ht_(insert_kv)(RZ_NONNULL HtName_(Ht) * ht, RZ_NONNULL HT_(Kv) * kv, bool update) { +RZ_API bool Ht_(insert_kv)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(Kv) *kv, bool update) { rz_return_val_if_fail(ht && kv, false); HT_(Kv) *kv_dst = reserve_kv(ht, kv->key, kv->key_len, update); if (!kv_dst) { @@ -248,7 +248,7 @@ RZ_API bool Ht_(insert_kv)(RZ_NONNULL HtName_(Ht) * ht, RZ_NONNULL HT_(Kv) * kv, return true; } -static bool insert_update(HtName_(Ht) * ht, const KEY_TYPE key, VALUE_TYPE value, bool update) { +static bool insert_update(HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value, bool update) { ut32 key_len = calcsize_key(ht, key); HT_(Kv) *kv_dst = reserve_kv(ht, key, key_len, update); if (!kv_dst) { @@ -267,7 +267,7 @@ static bool insert_update(HtName_(Ht) * ht, const KEY_TYPE key, VALUE_TYPE value * Inserts the key value pair \p key, \p value into the hashtable \p ht. * Doesn't allow for "update" of the value. */ -RZ_API bool Ht_(insert)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, VALUE_TYPE value) { +RZ_API bool Ht_(insert)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value) { rz_return_val_if_fail(ht, false); return insert_update(ht, key, value, false); } @@ -276,7 +276,7 @@ RZ_API bool Ht_(insert)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, VALUE_T * Inserts the key value pair \p key, \p value into the hashtable \p ht. * Does allow for "update" of the value. */ -RZ_API bool Ht_(update)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, VALUE_TYPE value) { +RZ_API bool Ht_(update)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, VALUE_TYPE value) { rz_return_val_if_fail(ht, false); return insert_update(ht, key, value, true); } @@ -284,7 +284,7 @@ RZ_API bool Ht_(update)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, VALUE_T /** * Update the key of an element that has \p old_key as key and replace it with \p new_key */ -RZ_API bool Ht_(update_key)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE old_key, const KEY_TYPE new_key) { +RZ_API bool Ht_(update_key)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE old_key, const KEY_TYPE new_key) { rz_return_val_if_fail(ht, false); // First look for the value associated with old_key bool found; @@ -302,7 +302,7 @@ RZ_API bool Ht_(update_key)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE old_key, // Remove the old_key kv, paying attention to not double free the value HT_(Bucket) *bt = &ht->table[bucketfn(ht, old_key)]; const int old_key_len = calcsize_key(ht, old_key); - HT_(Kv) * kv; + HT_(Kv) *kv; ut32 j; BUCKET_FOREACH(ht, bt, j, kv) { @@ -333,7 +333,7 @@ RZ_API bool Ht_(update_key)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE old_key, * If \p found is not NULL, it will be set to true if the entry was found, * false otherwise. */ -RZ_API RZ_BORROW HT_(Kv) * Ht_(find_kv)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, RZ_NULLABLE bool *found) { +RZ_API RZ_BORROW HT_(Kv) *Ht_(find_kv)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, RZ_NULLABLE bool *found) { if (found) { *found = false; } @@ -341,7 +341,7 @@ RZ_API RZ_BORROW HT_(Kv) * Ht_(find_kv)(RZ_NONNULL HtName_(Ht) * ht, const KEY_T HT_(Bucket) *bt = &ht->table[bucketfn(ht, key)]; ut32 key_len = calcsize_key(ht, key); - HT_(Kv) * kv; + HT_(Kv) *kv; ut32 j; BUCKET_FOREACH(ht, bt, j, kv) { @@ -360,7 +360,7 @@ RZ_API RZ_BORROW HT_(Kv) * Ht_(find_kv)(RZ_NONNULL HtName_(Ht) * ht, const KEY_T * If \p found is not NULL, it will be set to true if the entry was found, * false otherwise. */ -RZ_API VALUE_TYPE Ht_(find)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, RZ_NULLABLE bool *found) { +RZ_API VALUE_TYPE Ht_(find)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key, RZ_NULLABLE bool *found) { HT_(Kv) *res = Ht_(find_kv)(ht, key, found); return res ? res->value : HT_NULL_VALUE; } @@ -368,11 +368,11 @@ RZ_API VALUE_TYPE Ht_(find)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key, RZ_ /** * Deletes an entry from the hash table \p ht with key \p key, if the pair exists. */ -RZ_API bool Ht_(delete)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key) { +RZ_API bool Ht_(delete)(RZ_NONNULL HtName_(Ht) *ht, const KEY_TYPE key) { rz_return_val_if_fail(ht, false); HT_(Bucket) *bt = &ht->table[bucketfn(ht, key)]; ut32 key_len = calcsize_key(ht, key); - HT_(Kv) * kv; + HT_(Kv) *kv; ut32 j; BUCKET_FOREACH(ht, bt, j, kv) { @@ -392,13 +392,13 @@ RZ_API bool Ht_(delete)(RZ_NONNULL HtName_(Ht) * ht, const KEY_TYPE key) { * Apply \p cb for each KV pair in \p ht. * If \p cb returns false, the iteration is stopped. */ -RZ_API void Ht_(foreach)(RZ_NONNULL HtName_(Ht) * ht, RZ_NONNULL HT_(ForeachCallback) cb, RZ_NULLABLE void *user) { +RZ_API void Ht_(foreach)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(ForeachCallback) cb, RZ_NULLABLE void *user) { rz_return_if_fail(ht && cb); ut32 i; for (i = 0; i < ht->size; ++i) { HT_(Bucket) *bt = &ht->table[i]; - HT_(Kv) * kv; + HT_(Kv) *kv; ut32 j, count; BUCKET_FOREACH_SAFE(ht, bt, j, count, kv) { diff --git a/librz/util/ht/ht_sp.c b/librz/util/ht/ht_sp.c index d9f8fe30347..f4ecb8418f7 100644 --- a/librz/util/ht/ht_sp.c +++ b/librz/util/ht/ht_sp.c @@ -26,7 +26,7 @@ static void fini_kv_val(HT_(Kv) *kv, void *user) { * \param dup_val Function to making copy of a value when inserting * \param free_val Function to releasing a stored value */ -RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(HtStrOption key_opt, RZ_NULLABLE HT_(DupValue) dup_val, RZ_NULLABLE HT_(FreeValue) free_val) { +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt, RZ_NULLABLE HT_(DupValue) dup_val, RZ_NULLABLE HT_(FreeValue) free_val) { HT_(Options) opt = { .cmp = (HT_(ListComparator))strcmp, .hashfn = (HT_(HashFunction))sdb_hash, diff --git a/librz/util/ht/ht_ss.c b/librz/util/ht/ht_ss.c index af78d3750b5..ac0b31d8cd5 100644 --- a/librz/util/ht/ht_ss.c +++ b/librz/util/ht/ht_ss.c @@ -25,7 +25,7 @@ static void fini_kv_val(HT_(Kv) *kv, void *user) { * \param key_opt Defines how key is stored * \param val_opt Defines how value is stored */ -RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(HtStrOption key_opt, HtStrOption val_opt) { +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt, HtStrOption val_opt) { HT_(Options) opt = { .cmp = (HT_(ListComparator))strcmp, .hashfn = (HT_(HashFunction))sdb_hash, diff --git a/librz/util/ht/ht_su.c b/librz/util/ht/ht_su.c index d78f149bd26..7e2509f7145 100644 --- a/librz/util/ht/ht_su.c +++ b/librz/util/ht/ht_su.c @@ -13,7 +13,7 @@ static void fini_kv_key(HT_(Kv) *kv, RZ_UNUSED void *user) { * \brief Create a new hashtable * \param key_opt Defines how key is stored */ -RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(HtStrOption key_opt) { +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(HtStrOption key_opt) { HT_(Options) opt = { .cmp = (HT_(ListComparator))strcmp, .hashfn = (HT_(HashFunction))sdb_hash, diff --git a/librz/util/ht/ht_up.c b/librz/util/ht/ht_up.c index fa8bc09c31f..64604c82d0f 100644 --- a/librz/util/ht/ht_up.c +++ b/librz/util/ht/ht_up.c @@ -30,7 +30,7 @@ static void init_options(HT_(Options) *opt, HT_(DupValue) valdup, HT_(FreeValue) * \param valdup Function to making copy of a value when inserting * \param valfree Function to releasing a stored value */ -RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree) { +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree) { HT_(Options) opt; init_options(&opt, valdup, valfree); return internal_ht_new(ht_primes_sizes[0], 0, &opt); @@ -41,7 +41,7 @@ RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLAB * \param valdup Function to making copy of a value when inserting * \param valfree Function to releasing a stored value */ -RZ_API RZ_OWN HtName_(Ht) * Ht_(new_size)(ut32 initial_size, RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree) { +RZ_API RZ_OWN HtName_(Ht) *Ht_(new_size)(ut32 initial_size, RZ_NULLABLE HT_(DupValue) valdup, RZ_NULLABLE HT_(FreeValue) valfree) { HT_(Options) opt; init_options(&opt, valdup, valfree); return Ht_(new_opt_size)(&opt, initial_size); diff --git a/librz/util/ht/ht_uu.c b/librz/util/ht/ht_uu.c index 34fbd0a7a08..b2cef4457ec 100644 --- a/librz/util/ht/ht_uu.c +++ b/librz/util/ht/ht_uu.c @@ -10,7 +10,7 @@ /** * \brief Create a new hashtable */ -RZ_API RZ_OWN HtName_(Ht) * Ht_(new)(void) { +RZ_API RZ_OWN HtName_(Ht) *Ht_(new)(void) { HT_(Options) opt = { 0 }; return Ht_(new_opt)(&opt); }