Re: [PATCH v2 5/6] object_array: add and use `object_array_pop()`

2017-09-23 Thread Jeff King
On Sat, Sep 23, 2017 at 11:49:16AM +0200, Martin Ågren wrote: > >> void add_object_array_with_path(struct object *obj, const char *name, > >> struct object_array *array, unsigned mode, const char *path); > >> +/* > >> + * Returns NULL if the array is empty. Otherwise, returns the last object > >

Re: [PATCH v2 5/6] object_array: add and use `object_array_pop()`

2017-09-23 Thread Martin Ågren
On 23 September 2017 at 06:27, Jeff King wrote: > On Sat, Sep 23, 2017 at 01:34:53AM +0200, Martin Ågren wrote: > >> Introduce and use `object_array_pop()` instead. Release memory in the >> new function. Document that popping an object leaves the associated >> elements in limbo. > > The interface

Re: [PATCH v2 5/6] object_array: add and use `object_array_pop()`

2017-09-22 Thread Jeff King
On Sat, Sep 23, 2017 at 01:34:53AM +0200, Martin Ågren wrote: > In a couple of places, we pop objects off an object array `foo` by > decreasing `foo.nr`. We access `foo.nr` in many places, but most if not > all other times we do so read-only, e.g., as we iterate over the array. > But when we chang

[PATCH v2 5/6] object_array: add and use `object_array_pop()`

2017-09-22 Thread Martin Ågren
In a couple of places, we pop objects off an object array `foo` by decreasing `foo.nr`. We access `foo.nr` in many places, but most if not all other times we do so read-only, e.g., as we iterate over the array. But when we change `foo.nr` behind the array's back, it feels a bit nasty and looks like