diff options
author | Karthik Nayak <karthik.188@gmail.com> | 2015-06-13 21:37:29 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-08-03 19:24:07 +0200 |
commit | 1958a6eb5498c8a5ac5ba908833cc862b28759f9 (patch) | |
tree | 8094c961356cae5008535d5f11de6293aa93365f /ref-filter.c | |
parent | for-each-ref: introduce filter_refs() (diff) | |
download | git-1958a6eb5498c8a5ac5ba908833cc862b28759f9.tar.xz git-1958a6eb5498c8a5ac5ba908833cc862b28759f9.zip |
ref-filter: make 'ref_array_item' use a FLEX_ARRAY for refname
This would remove the need of using a pointer to store refname.
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ref-filter.c')
-rw-r--r-- | ref-filter.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ref-filter.c b/ref-filter.c index 7b39303810..3fbbbeb88f 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -847,8 +847,10 @@ static struct ref_array_item *new_ref_array_item(const char *refname, const unsigned char *objectname, int flag) { - struct ref_array_item *ref = xcalloc(1, sizeof(struct ref_array_item)); - ref->refname = xstrdup(refname); + 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'; hashcpy(ref->objectname, objectname); ref->flag = flag; @@ -889,7 +891,6 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid, static void free_array_item(struct ref_array_item *item) { free((char *)item->symref); - free(item->refname); free(item); } |