expanding argv[]
Chris Torek
chris at mimsy.UUCP
Fri Oct 7 05:11:32 AEST 1988
In article <660020 at hpclscu.HP.COM> shankar at hpclscu.HP.COM (Shankar Unni)
writes:
-Re: Expanding the argv array:
-
-Try:
-
- argv = (char **) realloc (argv, newsize * sizeof (char *))
- /* newsize is the size of your expanded argv array */
- for (ctr = OLDargc; ctr < newsize; ctr++)
- argv[ctr] = (char *) 0;
- /* now append arguments to your heart's content.. */
-
- /* NO COMMENTS ABOUT PASCAL'ish CODING!!! :-) */
There is nothing particularly Pascal-ish about this. It is, however,
wrong. argv[] is not allocated by malloc(), or not guaranteed to be so
allocated, and therefore it is wrong to call realloc on it.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list