Thread (67 messages) 67 messages, 6 authors, 2021-10-01

Re: [PATCH 2/8] builtin/multi-pack-index.c: support --stdin-packs mode

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-09-11 10:07:44

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().
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help