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
4
attr.c
4
attr.c
@ -93,9 +93,7 @@ static struct git_attr *git_attr_internal(const char *name, int len)
|
||||
if (invalid_attr_name(name, len))
|
||||
return NULL;
|
||||
|
||||
a = xmalloc(sizeof(*a) + len + 1);
|
||||
memcpy(a->name, name, len);
|
||||
a->name[len] = 0;
|
||||
FLEX_ALLOC_MEM(a, name, name, len);
|
||||
a->h = hval;
|
||||
a->next = git_attr_hash[pos];
|
||||
a->attr_nr = attr_nr++;
|
||||
|
Reference in New Issue
Block a user