On 12/09/18 00:49, Stefan Beller wrote: > Add a few functions to allow a string-list to be used as a stack: > > - string_list_last() lets a caller peek the string_list_item at the > end of the string list. The caller needs to be aware that it is > borrowing a pointer, which can become invalid if/when the > string_list is resized. > > - string_list_pop() removes the string_list_item at the end of > the string list. > > - _pop usually has a friend _push. This role is taken by > string_list_append already, as they are not symmetrical > in our code base: _append returns the pointer, such that > adding a util is easy, but _pop doesn't return such a pointer. > > You can use them in this pattern: > > while (list.nr) { > struct string_list_item *item = string_list_last(&list); > > work_on(item); > string_list_pop(&list); string_list_pop() takes a second int parameter (free_util). ATB, Ramsay Jones
- [PATCH 0/9] fetch: make sure submodule oids are fetched Stefan Beller
- [PATCH 2/9] sha1-array: provide oid_array_filter Stefan Beller
- Re: [PATCH 2/9] sha1-array: provide oid_array_filt... Junio C Hamano
- [PATCH 3/9] submodule.c: fix indentation Stefan Beller
- Re: [PATCH 3/9] submodule.c: fix indentation Junio C Hamano
- [PATCH 7/9] submodule: fetch in submodules git directo... Stefan Beller
- Re: [PATCH 7/9] submodule: fetch in submodules git... Junio C Hamano
- [PATCH 1/9] string-list: add string_list_{pop, last} f... Stefan Beller
- Re: [PATCH 1/9] string-list: add string_list_{pop,... Ramsay Jones
- Re: [PATCH 1/9] string-list: add string_list_{pop,... Junio C Hamano
- [PATCH 9/9] builtin/fetch: check for submodule updates... Stefan Beller
- Re: [PATCH 9/9] builtin/fetch: check for submodule... Junio C Hamano
- [PATCH 5/9] submodule: move global changed_submodule_n... Stefan Beller
- [PATCH 6/9] submodule.c: do not copy around submodule ... Stefan Beller
- [PATCH 8/9] fetch: retry fetching submodules if sha1 w... Stefan Beller
- Re: [PATCH 8/9] fetch: retry fetching submodules i... Junio C Hamano
- [PATCH 4/9] submodule.c: sort changed_submodule_names ... Stefan Beller
- Re: [PATCH 4/9] submodule.c: sort changed_submodul... Junio C Hamano