list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/5] Add struct strmap and associated utility functions
@ 2020-08-21 18:52 Elijah Newren via GitGitGadget
  2020-08-21 18:52 ` [PATCH 1/5] hashmap: add usage documentation explaining hashmap_free[_entries]() Elijah Newren via GitGitGadget
                   ` (6 more replies)
  0 siblings, 7 replies; 144+ messages in thread
From: Elijah Newren via GitGitGadget @ 2020-08-21 18:52 UTC (permalink / raw)
  To: git; +Cc: Jeff King, Elijah Newren

Here I introduce a new strmap type, which my new merge backed, merge-ort,
uses heavily. (I also made significant use of it in my changes to
diffcore-rename). This strmap type was based on Peff's proposal from a
couple years ago[1], but has additions that I made as I used it. I also
start the series off with a quick documentation improvement to hashmap.c to
differentiate between hashmap_free() and hashmap_free_entries(), since I
personally had difficulty understanding them and it affects how
strmap_clear()/strmap_free() are written.

The biggest issue I know about currently concerns the convenience functions
for a string->integer mapping. I wanted such a mapping that didn't need to
allocate an extra int but instead works by just type-casting the void*
pointer to an int instead. That all seems to work, but I needed a separate
name for that type, and the problem is that I couldn't come up with a good
one as you'll see in the last patch. Suggestions for better naming are very
much welcome. As are, of course, suggestions for other API or implementation


Elijah Newren (5):
  hashmap: add usage documentation explaining hashmap_free[_entries]()
  strmap: new utility functions
  strmap: add more utility functions
  strmap: add strdup_strings option
  strmap: add functions facilitating use as a string->int map

 Makefile  |   1 +
 hashmap.h |  27 +++++++++++-
 strmap.c  | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 strmap.h  | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 275 insertions(+), 2 deletions(-)
 create mode 100644 strmap.c
 create mode 100644 strmap.h

base-commit: 675a4aaf3b226c0089108221b96559e0baae5de9
Fetch-It-Via: git fetch pr-git-835/newren/strmap-v1

^ permalink raw reply	[flat|nested] 144+ messages in thread