tidwall / tidwall/hashmap.c

some functions now returning `const void *`

Open
#42 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1k
Forks
138
PR merge metrics
No merged PRs in 30d

Description

I noticed that in https://github.com/tidwall/hashmap.c/commit/84d0d3bf75f297443a5069b801ea13d93ee05e0a#diff-9257c021257b8c2773c58e19016dbd9499f0524100e98dd4616f8a9a55e8b13fR33 return types for hashmap_get, hashmap_set, hashmap_delete, and hashmap_probe were changed to constant. This is raising warnings on code that I have written previously.

Before I change the code on my end, I would like to understand the rationale behind this change. If the intent is to discourage changing the underlying bucket data, I understand the change in hashmap_get and hashmap_probe. For hashmap_set and hashmap_delete, however, I don't see the point in keeping the return values constant, since they are no longer managed by the hashmap. Can you explain? Thanks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the cited commit with the current declarations and implementations of hashmap_get, hashmap_set, hashmap_delete, and hashmap_probe. Determine the intended const behavior and document or resolve the API decision so existing callers’ warnings and the return-type rationale are addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend-api-design
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.