On Jun 7, 2010, at 2:38 PM, Jeff Johnson wrote:
> AFAIK, all POPT args are either returned by value (like POPT_ARG_INT) or
> through malloc'd memory _ALWAYS_. The rules on table callbacks are different
> than the rules for the no-brainer, in-line loop based getopt(3) like processing.
> OTOH, some of the code paths in POPT are quite twisty, perhaps there's someplace
> where another strdup/malloc is needed.
Here is poptPeekArg() (I happen to have on my screen):
const char * poptPeekArg(poptContext con)
const char * ret = NULL;
if (con && con->leftovers != NULL && con->nextLeftover < con->numLeftovers)
ret = con->leftovers[con->nextLeftover];
So no malloc with poptPeekArg() returns atm, largely for hysterical
Its easy enough to add strdup (or not) to poptPeekArg(). What isn't clear is
whether a consistent rule like
All memory is malloc'd before return.
is preferred to the mysteriously inconsistent current behavior in POPT.
73 de Jeff
Received on Mon Jun 14 17:17:15 2010