diff-no-index.c: use error_errno()
[gitweb.git] / attr.c
diff --git a/attr.c b/attr.c
index 086c08dcfab613ef2927ff2769797fa40cd03308..6537a433da201e866208ab23bf32bcafee037683 100644 (file)
--- a/attr.c
+++ b/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++;
@@ -799,7 +797,7 @@ int git_all_attrs(const char *path, int *num, struct git_attr_check **check)
                        ++count;
        }
        *num = count;
-       *check = xmalloc(sizeof(**check) * count);
+       ALLOC_ARRAY(*check, count);
        j = 0;
        for (i = 0; i < attr_nr; i++) {
                const char *value = check_all_attr[i].value;