use CALLOC_ARRAY
Add and apply a semantic patch for converting code that open-codes CALLOC_ARRAY to use it instead. It shortens the code and infers the element size automatically. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
f1121499e6
commit
ca56dadb4b
@ -76,7 +76,7 @@ unsigned int memihash_cont(unsigned int hash_seed, const void *buf, size_t len)
|
||||
static void alloc_table(struct hashmap *map, unsigned int size)
|
||||
{
|
||||
map->tablesize = size;
|
||||
map->table = xcalloc(size, sizeof(struct hashmap_entry *));
|
||||
CALLOC_ARRAY(map->table, size);
|
||||
|
||||
/* calculate resize thresholds for new size */
|
||||
map->grow_at = (unsigned int) ((uint64_t) size * HASHMAP_LOAD_FACTOR / 100);
|
||||
|
Reference in New Issue
Block a user