[torquedev] OS X outstanding issues

Glen Beane glen.beane at gmail.com
Thu Jan 15 06:20:33 MST 2009


On Wed, Jan 14, 2009 at 11:30 PM, Garrick <garrick at usc.edu> wrote:
> Wordexp() is called more than once and I expect wordfree() is necessary
> between calls.

>From looking at Apple's wordexp source code I don't think this is true.


It always initializes pwe->we_wordc to zero and pwe->we_wordv to NULL
(pwe is the name of the second parameter in the Apple source).
we_wordv would be the pointer to the memory allocated by a previous
call to wordexp if you are reusing pwe.  Even if you pass the
WRDE_REUSE flag all it does is call wordfree() before setting we_wordc
and we_wordv:


	if (flags & WRDE_REUSE) {
	    wordfree(pwe);
	}
	pwe->we_wordc = 0;
	pwe->we_wordv = NULL;



The harm of not calling wordfree() will be a memory leak, but since
this is a child of pbs_mom it isn't a problem.   I'm going to do some
tests later with wordfree() commented out.  It is sloppy, but I think
it might work until Apple fixes their code.


More information about the torquedev mailing list