rizin icon indicating copy to clipboard operation
rizin copied to clipboard

Implement one line `foreach` macros for hash tables.

Open Rot127 opened this issue 1 year ago • 1 comments

Your checklist for this pull request

  • [x] I've read the guidelines for contributing to this repository
  • [x] I made sure to follow the project's coding style
  • [x] I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • [x] I've added tests that prove my fix is effective or that my feature works (if possible)
  • [ ] I've updated the rizin book with the relevant information (if needed)

Detailed description

Adds one line foreach macros for hash tables and in extend sets.

Additionally:

  • Renames the already existing for each mechanism to ht_foreach_cb (cb for call back), so they can be distinguished.
  • it adds a ht_xx_size() function for simpler access to the ht->count member.
  • Renames file for hash table unit tests from test_sdb_hash.c to test_ht.c. Because it was hard to find before with a search.

Test plan

Tests added.

Closing issues

...

Rot127 avatar May 18 '24 12:05 Rot127

@Rot127 one bindgen linter error:

Mismatched function annotation for rz_set_s_size at <rizin/librz/include/rz_util/rz_set.h:23:13> : RZ_NONNULL (was RZ_NULLABLE at <rizin/librz/util/set.c:75:13>

XVilka avatar May 18 '24 16:05 XVilka

Please rebase.

XVilka avatar Sep 17 '24 10:09 XVilka

Superseded by https://github.com/rizinorg/rizin/pull/4639

Rot127 avatar Sep 18 '24 09:09 Rot127