On Wed, 28 Nov 2012 14:25:07 +0100, Mark Wielaard wrote:
> I could comment it otherwise but I have created a new
Dwfl_module field
> instead. It was too fragile to use USERDATA, in fact it made USERDATA
> unavailable for anything else from applications.
I think it would be better to use a global static in argp-std.c.
dwfl_standard_argp () returns a global static argp pointer, so it cannot
really be reused anyway and there can be only one executable per
Dwfl/argp. You do allocate the parse_opt dynamically, but it looks to me
that it could just as well be static like libdwfl_argp. Or am I missing
a use case?
# static const struct argp libdwfl_argp =
# { .options = options, .parser = parse_opt };
#
# const struct argp *
# dwfl_standard_argp (void)
# {
# return &libdwfl_argp;
# }
What returns dwfl_standard_argp is irrelevant, it is const anyway.
Modifiable is struct argp_state:
# static error_t
# parse_opt (int key, char *arg, struct argp_state *state)
But one can call parse_opt for arbitrary number of different struct argp_state
structures in arbitrary order in arbitrary states of their execution (even if
no threads are in use).
Is there still a disagreement?
Thanks,
Jan