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