Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uflorida!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: expanding argv[] Message-ID: <13893@mimsy.UUCP> Date: 6 Oct 88 19:11:32 GMT References: <1239500004@osiris.cso.uiuc.edu> <660020@hpclscu.HP.COM> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 20 In article <660020@hpclscu.HP.COM> shankar@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@mimsy.umd.edu Path: uunet!mimsy!chris