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];
    return ret;
}

So no malloc with poptPeekArg() returns atm, largely for hysterical
reasons.

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
______________________________________________________________________
POPT Library                                           http://rpm5.org
Developer Communication List                       popt-devel@rpm5.org

Reply via email to