On Thu, Aug 9, 2018 at 2:56 PM Jeff King wrote:
>
> I think you could have helpers to spell the two lines above even more
> nicely:
>
> while (list->nr) {
> work_on(list_top(list));
> list_pop(list); /* note this doesn't return anything! */
> }
>
> But yes, it's not possible
On Thu, Aug 09, 2018 at 02:52:29PM -0700, Stefan Beller wrote:
> > In many cases you can just do:
> >
> > while (list->nr) {
> > work_on(list->items[list->nr - 1]);
> > list_remove(list, list->nr - 1);
> > }
> >
> > and then all of those memory ownership issues like:
>
>
On Thu, Aug 9, 2018 at 2:41 PM Jeff King wrote:
> >
> > while (list->nr)
> > work_on(list_pop(list));
> >
> > which is not so bad.
>
> In many cases you can just do:
>
> while (list->nr) {
> work_on(list->items[list->nr - 1]);
> list_remove(list, list->nr -
On Thu, Aug 09, 2018 at 02:29:32PM -0700, Junio C Hamano wrote:
> >> +struct string_list_item *string_list_pop(struct string_list *list)
> >> +{
> >> + if (list->nr == 0)
> >> + return 0;
> >
> > return NULL, not 0.
>
> It is OK to return NULL, which may make the caller a bit
Martin Ågren writes:
> On 9 August 2018 at 00:17, Stefan Beller wrote:
>> A string list can be used as a stack, but should we? A later patch shows
>> how useful this will be.
>>
>> Signed-off-by: Stefan Beller
>> ---
>> string-list.c | 8
>> string-list.h | 6 ++
>> 2 files
On 9 August 2018 at 00:17, Stefan Beller wrote:
> A string list can be used as a stack, but should we? A later patch shows
> how useful this will be.
>
> Signed-off-by: Stefan Beller
> ---
> string-list.c | 8
> string-list.h | 6 ++
> 2 files changed, 14 insertions(+)
>
> diff
A string list can be used as a stack, but should we? A later patch shows
how useful this will be.
Signed-off-by: Stefan Beller
---
string-list.c | 8
string-list.h | 6 ++
2 files changed, 14 insertions(+)
diff --git a/string-list.c b/string-list.c
index 9f651bb4294..ea80afc8a0c
7 matches
Mail list logo