Q: Realloc of function parameter problem.
Conor P. Cahill
cpcahil at virtech.uucp
Mon Nov 27 06:56:01 AEST 1989
In article <3752 at umiami.miami.edu>, SLORES at umiami.miami.edu (Stanislaw L. Olejniczak) writes:
> *substr = (char *) realloc ( (unsigned) (numchar + 1), *substr);
First, you must RTFM. The order of arguments to realloc is:
realloc(ptr,size);
char * ptr;
unsigned size;
Second, although not explicitly stated in the manual, the pointer passed
to realloc must be a ptr that was returned by a previous malloc. Your
example was passing a pointer to an automatic variable.
--
+-----------------------------------------------------------------------+
| Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 !
| Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 |
+-----------------------------------------------------------------------+
More information about the Comp.lang.c
mailing list