summaryrefslogtreecommitdiff
path: root/khash.h
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-09-16 20:56:57 +0200
committerJunio C Hamano <gitster@pobox.com>2014-09-18 09:13:42 -0700
commit2756ca4347cbda05b16954cd7f445c216b935e76 (patch)
tree70afb2d44557fd05bbc0707c190c6026ab6135fd /khash.h
parent3ac22f82edec108986b2627fcd6f2a8039617a23 (diff)
downloadgit-2756ca4347cbda05b16954cd7f445c216b935e76.tar.gz
use REALLOC_ARRAY for changing the allocation size of arraysrs/realloc-array
Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'khash.h')
-rw-r--r--khash.h12
1 files changed, 4 insertions, 8 deletions
diff --git a/khash.h b/khash.h
index 06c7906549..376475a5ea 100644
--- a/khash.h
+++ b/khash.h
@@ -121,13 +121,9 @@ static const double __ac_HASH_UPPER = 0.77;
if (!new_flags) return -1; \
memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
if (h->n_buckets < new_n_buckets) { /* expand */ \
- khkey_t *new_keys = (khkey_t*)xrealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
- if (!new_keys) return -1; \
- h->keys = new_keys; \
+ REALLOC_ARRAY(h->keys, new_n_buckets); \
if (kh_is_map) { \
- khval_t *new_vals = (khval_t*)xrealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
- if (!new_vals) return -1; \
- h->vals = new_vals; \
+ REALLOC_ARRAY(h->vals, new_n_buckets); \
} \
} /* otherwise shrink */ \
} \
@@ -160,8 +156,8 @@ static const double __ac_HASH_UPPER = 0.77;
} \
} \
if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \
- h->keys = (khkey_t*)xrealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
- if (kh_is_map) h->vals = (khval_t*)xrealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
+ REALLOC_ARRAY(h->keys, new_n_buckets); \
+ if (kh_is_map) REALLOC_ARRAY(h->vals, new_n_buckets); \
} \
free(h->flags); /* free the working space */ \
h->flags = new_flags; \