From: Eric Wong Date: Mon, 01 Aug 2016 22:34:47 GMT Subject: Re: [[PATCH v2] 1/4] patch-ids: stop using a hand-rolled hashmap implementation Message-ID: <20160801223447.GA10924@whir> In-Reply-To: Junio C Hamano wrote: > Johannes Schindelin writes: > > > 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) > 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/