summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-12-11 19:54:56 -0500
committerJune McEnroe <june@causal.agency>2020-12-11 19:54:56 -0500
commitfe6083493e959836c1a7280823a6820ab5341938 (patch)
treeb19b755cadb8de3ff21aa2f08ddd248447039d24
parentAdd -i to idle (diff)
downloadbubger-fe6083493e959836c1a7280823a6820ab5341938.tar.gz
bubger-fe6083493e959836c1a7280823a6820ab5341938.zip
Free threads and envelopes after concat
Kind of important for the idle loop huh.
Diffstat (limited to '')
-rw-r--r--archive.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/archive.c b/archive.c
index 756f822..86f0687 100644
--- a/archive.c
+++ b/archive.c
@@ -218,6 +218,7 @@ examine:;
 
 concat:;
 	enum Atom concat = atom("concat");
+	struct List envelopeItems = {0};
 	struct Envelope *envelopes = calloc(threads.len, sizeof(*envelopes));
 	if (!envelopes) err(EX_OSERR, "calloc");
 	concatFetch(imap.w, concat, threads);
@@ -227,12 +228,21 @@ concat:;
 		// Prevent freeing data in envelopes with resp:
 		struct Data items = dataTake(&resp.data.ptr[0]);
 		concatData(threads, envelopes, dataCheck(items, List).list);
+		listPush(&envelopeItems, items);
 	}
 	respFree(resp);
 
 	concatThreads(threads, envelopes);
 	concatIndex(threads, envelopes);
 	uidWrite("UIDNEXT", uidNext);
+
+	for (size_t i = 0; i < threads.len; ++i) {
+		envelopeFree(envelopes[i]);
+	}
+	free(envelopes);
+	listFree(envelopeItems);
+	listFree(threads);
+
 	if (!idle) goto logout;
 
 idle: