How big is the argv[] array?

Gordon Cross crossgl at ingr.UUCP
Tue Nov 1 03:44:43 AEST 1988


In article <10033 at socslgw.csl.sony.JUNET>, diamond at csl.sony.JUNET (Norman Diamond) writes:
> 
> What does realloc do when its first argument is a pointer to storage
> that was not obtained by malloc?  Maybe you won't crash until your
> program exits and the shell reads the next command line?

My experience with these types of problems is that (assumming the memory is
writable) realloc simply assumes that the pointer it has been handed 
(excepting the NULL case which many implementations treat as if malloc had
been called) was previously allocated via malloc.  If the realloc call does
not cause some sort of memory fault (and in many cases it may not) it winds
up corrupting the data structures that malloc uses.  Eventually the program
will likely abort (I don't like the word "crash" - it implies a system crash)
but during a subsequent call to malloc, realloc, calloc, or free....


Gordon Cross
Intergraph Corp.  Huntsville, AL



More information about the Comp.lang.c mailing list