Junio C Hamano [off-list ref] wrote:
Johannes Schindelin [off-list ref] writes:
quoted
It would be a serious bug if hashmap_entry_init() played games with
references, given its signature (that this function does not have any
access to the hashmap structure, only to the entry itself):
void hashmap_entry_init(void *entry, unsigned int hash)
<snip>
I have a slight preference to avoid the lazy "void *", but that is
an unrelated tangent.
Me too. I noticed this while working on the http-walker
speedups and my self-rejected last patch:
https://public-inbox.org/git/20160711210243.GA1604%40whir/
Extracting list_entry from list.h (currently in next[1]) and
exposing that generically as "container_of" for use with
hashmap_* would make it safer-to-use and allow structs to belong
to multiple hashmaps.
list_entry is also an alias for container_of in the Linux
kernel, but we don't have enough code using list_* to
warrant two names for the same macro.
[1] https://public-inbox.org/git/20160711205131.1291-4-e%4080x24.org/