mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
convert trivial cases to FLEX_ARRAY macros
Using FLEX_ARRAY macros reduces the amount of manual computation size we have to do. It also ensures we don't overflow size_t, and it makes sure we write the same number of bytes that we allocated. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
3733e69464
commit
96ffc06f72
@@ -256,10 +256,9 @@ const void *memintern(const void *data, size_t len)
|
||||
e = hashmap_get(&map, &key, data);
|
||||
if (!e) {
|
||||
/* not found: create it */
|
||||
e = xmallocz(sizeof(struct pool_entry) + len);
|
||||
FLEX_ALLOC_MEM(e, data, data, len);
|
||||
hashmap_entry_init(e, key.ent.hash);
|
||||
e->len = len;
|
||||
memcpy(e->data, data, len);
|
||||
hashmap_add(&map, e);
|
||||
}
|
||||
return e->data;
|
||||
|
||||
Reference in New Issue
Block a user