From 24001221628d9e060a25c3cefe191860f305552d Mon Sep 17 00:00:00 2001 From: Al Date: Thu, 9 Mar 2017 00:54:31 -0500 Subject: [PATCH] [fix] fixing up hash str to id template --- src/collections.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/collections.h b/src/collections.h index 971787fd..48c0f2ec 100644 --- a/src/collections.h +++ b/src/collections.h @@ -144,6 +144,7 @@ KHASH_STR_INCR(str_uint32, uint32_t) k = kh_get(name, h, key); \ if (k == kh_end(h)) { \ char *key_copy = strdup(key); \ + val_type new_id = (val_type)kh_size(h); \ if (key_copy == NULL) { \ return false; \ } \ @@ -152,8 +153,12 @@ KHASH_STR_INCR(str_uint32, uint32_t) free(key_copy); \ return false; \ } \ - kh_value(h, k) = (val_type)kh_size(h); \ + kh_value(h, k) = new_id; \ + *val = new_id; \ *exists = false; \ + return true; \ + } else { \ + *exists = true; \ } \ *val = kh_value(h, k); \ return true; \