I looked at 19.d and I think the design has gotten pretty convoluted. I
think we could simplify with the following changes:
struct script_t gets a new member, of type Command **, which is
initially null.
function process_builtin receives the complete script_t (not individual
memebers of it) constructs the Command ** array and puts it in
script_t's new member; return value is the same script_t struct it got
(except it's now augmented with the Command **array).
function process_file constructs a new script_t from the string list,
creates its Command **array just like process_builtin and returns the
constructed struct.
function addScript receives script_t instead of individual members of
it, and does the appropriate thing.
Alternatively, we could have a different struct that's defined to carry
only the Command ** array (not the command string array) and is returned
by both process_builtin and process_file. Perhaps we could also put the
script weight in there. With this arrangement we don't need to typedef
script_t at all and we can just keep it as an anonymous struct as today.
This is what I tried to describe earlier, but obviously I wasn't clear
enough.
Thanks,
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services