On Thu, 10 Nov 2011, Jakub Jelinek wrote:

> Hi!
> 
> Running valgrind even on simple testcases shows a bunch of
> memory leaks (definitely lost).  This patch cures some of them.
> There are a few further leaks in the options handling.
> 
> The first hunk is when this function already called concat to set
> opt_text, and then doesn't write opt_text anywhere, but concat
> of that and something else (which malloces a new memory and doesn't
> free the old one).

The option-handling change is OK.  But I suspect eliminating memory leaks 
completely from option handling will require defining various fields, that 
may at present sometimes hold malloced memory and sometimes hold pointers 
into constant data or the original command line, always to hold malloced 
memory (and so require various new allocations that aren't required at 
present) - as without defining that there are probably cases where you 
won't know whether to free the previous value of a field.  (I've generally 
presumed that memory usage that is O(n) in the size of the command line 
isn't significant.)

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to