clibs/which — pull request #6 by stephenmathieson (2014-02-27 15:21:28+00:00)
Title: Fix `path` leak

Before:

```
$ valgrind --leak-check=full ./example clib
==3509== Memcheck, a memory error detector
==3509== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==3509== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==3509== Command: ./example clib
==3509==
clib: /usr/local/bin/clib
==3509==
==3509== HEAP SUMMARY:
==3509== in use at exit: 105 bytes in 2 blocks
==3509== total heap usage: 3 allocs, 1 frees, 126 bytes allocated
==3509==
==3509== 20 bytes in 1 blocks are definitely lost in loss record 1 of 2
==3509== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3509== by 0x400954: which_path (in /home/stephen/which/example)
==3509== by 0x40089F: which (in /home/stephen/which/example)
==3509== by 0x40083E: main (in /home/stephen/which/example)
==3509==
==3509== 85 bytes in 1 blocks are definitely lost in loss record 2 of 2
==3509== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3509== by 0x400A25: str_copy (in /home/stephen/which/example)
==3509== by 0x4008BD: which_path (in /home/stephen/which/example)
==3509== by 0x40089F: which (in /home/stephen/which/example)
==3509== by 0x40083E: main (in /home/stephen/which/example)
==3509==
==3509== LEAK SUMMARY:
==3509== definitely lost: 105 bytes in 2 blocks
==3509== indirectly lost: 0 bytes in 0 blocks
==3509== possibly lost: 0 bytes in 0 blocks
==3509== still reachable: 0 bytes in 0 blocks
==3509== suppressed: 0 bytes in 0 blocks
==3509==
==3509== For counts of detected and suppressed errors, rerun with: -v
==3509== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 2 from 2)
```

After:

```
$ valgrind --leak-check=full ./example clib
==3453== Memcheck, a memory error detector
==3453== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==3453== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==3453== Command: ./example clib
==3453==
clib: /usr/local/bin/clib
==3453==
==3453== HEAP SUMMARY:
==3453== in use at exit: 0 bytes in 0 blocks
==3453== total heap usage: 3 allocs, 3 frees, 126 bytes allocated
==3453==
==3453== All heap blocks were freed -- no leaks are possible
==3453==
==3453== For counts of detected and suppressed errors, rerun with: -v
==3453== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
```