Merge branch 'jk/tighten-alloc'
[gitweb.git] / ref-filter.c
index d13d002270f3b0a04c2e7b5669dc87dba9132b79..bb79d6b9cc0f5aec16eb1dffb842910ba55e99ab 100644 (file)
@@ -1321,10 +1321,8 @@ static struct ref_array_item *new_ref_array_item(const char *refname,
                                                 const unsigned char *objectname,
                                                 int flag)
 {
-       size_t len = strlen(refname);
-       struct ref_array_item *ref = xcalloc(1, sizeof(struct ref_array_item) + len + 1);
-       memcpy(ref->refname, refname, len);
-       ref->refname[len] = '\0';
+       struct ref_array_item *ref;
+       FLEX_ALLOC_STR(ref, refname, refname);
        hashcpy(ref->objectname, objectname);
        ref->flag = flag;