Skip to content

Commit

Permalink
Constify get-size() of hash tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Sep 18, 2024
1 parent 35f10e2 commit 47f96f3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion librz/include/rz_util/ht_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ HT_(IterState);
// Create a new Ht with the provided Options
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)(const 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);
// Insert a new Key-Value pair into the hashtable. If the key already exists, returns false.
Expand Down
4 changes: 2 additions & 2 deletions librz/include/rz_util/rz_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RZ_API void rz_set_s_free(RZ_NULLABLE RzSetS *set);
RZ_API void rz_set_s_add(RZ_NONNULL RzSetS *set, const char *str);
RZ_API bool rz_set_s_contains(RZ_NONNULL RzSetS *set, const char *str);
RZ_API void rz_set_s_delete(RZ_NONNULL RzSetS *set, const char *str);
RZ_API ut32 rz_set_s_size(RZ_NONNULL RzSetS *set);
RZ_API ut32 rz_set_s_size(const RZ_NONNULL RzSetS *set);
RZ_API RZ_OWN RzPVector /*<char *>*/ *rz_set_s_to_vector(RZ_NONNULL RzSetS *set);
RZ_API RzIterator *rz_set_s_as_iter(const RZ_NONNULL RzSetS *set);

Expand All @@ -31,7 +31,7 @@ RZ_API void rz_set_u_free(RZ_NULLABLE RzSetU *set);
RZ_API void rz_set_u_add(RZ_NONNULL RzSetU *set, ut64 u);
RZ_API bool rz_set_u_contains(RZ_NONNULL RzSetU *set, ut64 u);
RZ_API void rz_set_u_delete(RZ_NONNULL RzSetU *set, ut64 u);
RZ_API ut32 rz_set_u_size(RZ_NULLABLE RzSetU *set);
RZ_API ut32 rz_set_u_size(const RZ_NONNULL RzSetU *set);
RZ_API RzIterator *rz_set_u_as_iter(const RZ_NONNULL RzSetU *set);

#ifdef __cplusplus
Expand Down
3 changes: 2 additions & 1 deletion librz/util/ht/ht_inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ RZ_API void Ht_(foreach)(RZ_NONNULL HtName_(Ht) *ht, RZ_NONNULL HT_(ForeachCallb
*
* \return The number of elements saved in the hash map.
*/
RZ_API ut32 Ht_(size)(RZ_NONNULL HtName_(Ht) *ht) {
RZ_API ut32 Ht_(size)(const RZ_NONNULL HtName_(Ht) *ht) {
rz_return_val_if_fail(ht, 0);
return ht->count;
}

Expand Down
6 changes: 4 additions & 2 deletions librz/util/set.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ RZ_API void rz_set_s_free(RZ_NULLABLE RzSetS *set) {
/**
* \brief Return number of elements saved in the set.
*/
RZ_API ut32 rz_set_s_size(RZ_NULLABLE RzSetS *set) {
RZ_API ut32 rz_set_s_size(const RZ_NONNULL RzSetS *set) {
rz_return_val_if_fail(set, 0);
return ht_sp_size((HtSP *)set);
}

Expand Down Expand Up @@ -120,7 +121,8 @@ RZ_API void rz_set_u_free(RZ_NULLABLE RzSetU *set) {
/**
* \brief Return number of elements saved in the set.
*/
RZ_API ut32 rz_set_u_size(RZ_NULLABLE RzSetU *set) {
RZ_API ut32 rz_set_u_size(const RZ_NONNULL RzSetU *set) {
rz_return_val_if_fail(set, 0);
return ht_up_size((HtUP *)set);
}

Expand Down

0 comments on commit 47f96f3

Please sign in to comment.