I never need to read the key string back out of the map though. Is it possible to use the map in such a way that the key buffer doesn’t need to be persisted, only its hash? E.g.
I see there are a bunch of variant methods with “context” and “adapted” in the names. I don’t understand what those do yet, so maybe what I want can be done with those somehow?
Not in general, since having the hash is not always enough to check for a match – think of hash collisions, in which case you do need to compare with the full string.
You can make it a bit easier for yourself by using an ArenaAllocator. That way you don’t need to manually free all the strings you allocated, instead you only need to free the arena.