On Tue, 2013-08-06 at 12:55 +0200, David Henningsson wrote: > On 08/06/2013 11:02 AM, Arun Raghavan wrote: > > This is handy for cases where we want to have the key freed at entry > > removal or hashmap free'ing time. For example, this is useful when > > creating a hashmap based on non-static strings. > > I agree about the problem about string keys, but I think the > implementation could be more elegant: > > 1) The free_cb functions could be supplied with pa_hashmap_new and > stored inside the hashmap, rather than being supplied in several places. I did want to go this way originally, but it's a lot of non-scriptable changes (~80 call sites). Tanu also had the same preference. Let me try to rework the patch to do this, though not sure when I'll be able to do that. > 2) This applies mostly to strings. Could we perhaps make a convenience > layer for string-key hashmaps, like this: > > pa_hashmap_put_strkey(const char *strkey, void *value) { > void *key = pa_strdup(strkey); > pa_hashmap_put(key, value); > } > > ...and similar for other functions, when necessary? I think it might be easier to read explicit pa_xstrdup() in the pa_hashmap_put than to hide away this detail in a call. Thanks, Arun