On Fri, Sep 10 2021, Taylor Blau wrote:
+ struct strbuf buf = STRBUF_INIT;
+ while (strbuf_getline(&buf, stdin) != EOF) {
+ string_list_append(to, strbuf_detach(&buf, NULL));
If you strbuf_detach() it...
+ struct string_list packs = STRING_LIST_INIT_NODUP;
...init the list with NODUP...
+ string_list_clear(&packs, 0);
...and call string_list_clear() you'll leak memory, since the
string_list will think that someone else is taking care of this memory.
I had some recent musings about how this API is bad, and I've got local
WIP patches to fix it, but in the meantime you need to:
packs.strdup_strings = 1;
Before calling string_list_clear(). I.e. we didn't strdup(), but during
free() we pretend that we did, because we did, just not in
string_list_append().