diff options
author | René Scharfe <l.s.r@web.de> | 2018-10-04 17:10:54 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-10-04 20:12:13 +0200 |
commit | 9249ca26aca3ae3f21f812593c7a5498736ae29a (patch) | |
tree | ee63b8fcf9317cec229b2901af4bf19b74f93bcf /khash.h | |
parent | fetch-pack: load tip_oids eagerly iff needed (diff) | |
download | git-9249ca26aca3ae3f21f812593c7a5498736ae29a.tar.xz git-9249ca26aca3ae3f21f812593c7a5498736ae29a.zip |
khash: factor out kh_release_*
Add a function for releasing the khash-internal allocations, but not the
khash structure itself. It can be used with on-stack khash structs.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r-- | khash.h | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -82,11 +82,16 @@ static const double __ac_HASH_UPPER = 0.77; SCOPE kh_##name##_t *kh_init_##name(void) { \ return (kh_##name##_t*)xcalloc(1, sizeof(kh_##name##_t)); \ } \ + SCOPE void kh_release_##name(kh_##name##_t *h) \ + { \ + free(h->flags); \ + free((void *)h->keys); \ + free((void *)h->vals); \ + } \ SCOPE void kh_destroy_##name(kh_##name##_t *h) \ { \ if (h) { \ - free((void *)h->keys); free(h->flags); \ - free((void *)h->vals); \ + kh_release_##name(h); \ free(h); \ } \ } \ |