+ return leaks;
+}
+
+/* Returns leaks, and sets errs[] */
+static char *analyze_output(const char *output, char **errs)
+{
+ char *leaks = tal_strdup(output, "");
+ unsigned int i;
+ char **lines = tal_strsplit(output, output, "\n", STR_EMPTY_OK);
+
+ *errs = tal_strdup(output, "");
+ for (i = 0; i < tal_count(lines) - 1; i++) {
+ unsigned int preflen = strspn(lines[i], "=0123456789");
+ char *prefix, **sublines;
+
+ /* Ignore erased lines, or weird stuff. */
+ if (preflen == 0)
+ continue;
+
+ prefix = tal_strndup(output, lines[i], preflen);
+ sublines = extract_matching(prefix, lines);
+
+ leaks = tal_strcat(output, take(leaks),
+ take(get_leaks(sublines, errs)));
+ }
+