RE: [Sablevm-developer] Re: Config File Parsing
Brought to you by:
egagnon
From: Brent F. <bre...@xp...> - 2000-12-05 22:06:11
|
I've got a stupid C question: Is it possible to modify the char* vector "argv" passed from the command line? Based on our earlier e-mail, I would anticipate the following: 1. User starts sablevm with one or two command line options. 2. SableVM opens and parses the /etc/sablevm file. (This works) 3. SableVM must then insert options from the /etc/sablevm file into the argv that gets passed to the "popt" library for parsing. How does this work? I tried a realloc on the argv vector, but that caused a segfault. In fact, more generally, how do you do something like this: int main() { char* args[3] = { "--foo", "--bar", "--baz" }; int argc = 3; do_something(&argc, args); } void do_something(int* argc, char** argv) { /* Add some new fields */ char* data = realloc(*args, 1000); /* I think this actually just macs args[0] = a buffer of size 1000. It doesn't grow the whole block. */ data[4] = "--more_stuff"; /* I think this ... } The problem I'm having is with conceptualizing pointer-to-pointer versus array-of-pointers. How can I achieve the desired behavior of basically "growing" an array of pointers? I know how I would achieve this under C++, but I'm unclear as to the proper behavior under C. Any help *greatly* appreciated. Thanks, -Brent |