I ran "make check" on valgrind-wrapped tools (took most of a day on a 6/12-core system) and saw split at the top of the list of "definitely lost buffer" leaks. So far, the only ones I've investigated are not important, but at least now, they are plugged and will not distract us further:
>From 32f7dd1ad64165cdde0c8d90997c2a6445965c00 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Thu, 2 Aug 2012 19:31:36 +0200 Subject: [PATCH 1/2] split: free a lines/round-robin chunk processing buffer * src/split.c (lines_rr): Plug a harmless leak. --- src/split.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/split.c b/src/split.c index 7ba743c..778949f 100644 --- a/src/split.c +++ b/src/split.c @@ -1044,6 +1044,7 @@ no_filters: files[i_file].ofd = OFD_APPEND; } } + free (files); } #define FAIL_ONLY_ONE_WAY() \ -- 1.7.12.rc1.10.g97c7934 >From 8aaa2fb61287b92562edd0f1d1520719fb13c9ff Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Fri, 3 Aug 2012 12:20:03 +0200 Subject: [PATCH 2/2] split: plug a nominal leak * src/split.c (main): Free a usually-small (~70KB) buffer just before exit, mainly to take this off the radar of leak-detecting tools. --- src/split.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/split.c b/src/split.c index 778949f..43cce6c 100644 --- a/src/split.c +++ b/src/split.c @@ -1076,7 +1076,6 @@ main (int argc, char **argv) { enum Split_type split_type = type_undef; size_t in_blk_size = 0; /* optimal block size of input file device */ - char *buf; /* file i/o buffer */ size_t page_size = getpagesize (); uintmax_t k_units = 0; uintmax_t n_units; @@ -1383,7 +1382,8 @@ main (int argc, char **argv) file_size = MAX (file_size, n_units); } - buf = ptr_align (xmalloc (in_blk_size + 1 + page_size - 1), page_size); + void *b = xmalloc (in_blk_size + 1 + page_size - 1); + char *buf = ptr_align (b, page_size); /* When filtering, closure of one pipe must not terminate the process, as there may still be other streams expecting input from us. */ @@ -1433,6 +1433,8 @@ main (int argc, char **argv) abort (); } + free (b); + if (close (STDIN_FILENO) != 0) error (EXIT_FAILURE, errno, "%s", infile); closeout (NULL, output_desc, filter_pid, outfile); -- 1.7.12.rc1.10.g97c7934
