Re: [RFC/PATCH 09/11] branch.c: use 'ref-filter' data structures
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jul 28, 2015, 13:48 UTC
- Message-ID
- <vpqa8ugwfyf.fsf@anie.imag.fr>
- In-Reply-To
- <CAP8UFD3L4QEYQMCda7AbByXGZcvgy5r9y0LMBqEysb6AZ+ydOQ@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
Show 8 quoted lines
> On Tue, Jul 28, 2015 at 8:56 AM, Karthik Nayak <karthik.188@gmail.com> wrote:
>
>> +static void ref_array_append(struct ref_array *array, const char *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';This looks very much like new_ref_array_item, except that the later also takes an objectname parameter. I find it suspicious that you leave the objectname field uninitialized.
Why is this code not calling new_ref_array_item?
A detail: you could return a pointer to the newly allocated object to write
item = ref_array_append(array, refname);
instead of
ref_array_append(array, refname); item = array->items[array->nr - 1];
Show 5 quoted lines
>> + REALLOC_ARRAY(array->items, array->nr + 1);
>> + array->items[array->nr++] = ref;
>> +}
>
> This function belongs more to ref-filter.{c,h}...The function disapears in the next commit, but I also think that this function deserves to exist in ref-filter.{c,h} and remain after the end of the series.
-- Matthieu Moy http://www-verimag.imag.fr/~moy/