Skip to content

util/ht: add key-value pair iterator support#6483

Open
thiagomucci wants to merge 1 commit into
rizinorg:devfrom
thiagomucci:ht-iter-kv
Open

util/ht: add key-value pair iterator support#6483
thiagomucci wants to merge 1 commit into
rizinorg:devfrom
thiagomucci:ht-iter-kv

Conversation

@thiagomucci
Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository.
  • I made sure to follow the project's coding style.
  • I've documented every RZ_API function and struct this PR changes.
  • x] I've added tests that prove my changes are effective (required for changes to RZ_API).
  • I've updated the Rizin book with the relevant information (if needed).
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description

This pull request implements a Key-Value pair iterator for the generic hashtable API (Ht_).
It introduces two new functions to the Doxygen/C template architecture in ht_inc.h:

  • Ht_(as_iter_kv): Creates an iterator to traverse both keys and values.
  • Ht_(iter_next_kv): Returns the next HT_(Kv) element in the iteration.

This allows developers to iterate over generic hashtables and access both keys and values simultaneously without needing separate lookups.

AI Disclosure: Gemini was used to debugging the Meson/Ninja local environment, and drafting the unit tests.

Test plan
I have created a dedicated unit test test_ht_uu_iter_kv inside test/unit/test_ht.c. The test populates an HtUU table, initializes the new KV iterator, and asserts that all pairs are traversed correctly.

Test plan
To run and verify the test, i execute:
meson compile -C build
meson test -C build --suite util

...

Closing issues

Closes #6426

...

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 7, 2026

Codecov Report

❌ Patch coverage is 72.22222% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.29%. Comparing base (d723950) to head (08de586).
⚠️ Report is 8 commits behind head on dev.

Files with missing lines Patch % Lines
librz/util/ht/ht_inc.c 72.22% 1 Missing and 4 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
librz/include/rz_util/ht_inc.h 100.00% <ø> (ø)
librz/util/ht/ht_inc.c 76.22% <72.22%> (-0.20%) ⬇️

... and 36 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d723950...08de586. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thiagomucci thiagomucci force-pushed the ht-iter-kv branch 2 times, most recently from b69fadb to f997d92 Compare June 8, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a hash table iterator over key/value pairs

1 participant