What happens when realloc() returns NULL?

david.f.prosser dfp at cbnewsl.ATT.COM
Fri Sep 1 01:23:59 AEST 1989


In article <TOM.89Aug30231415 at yang.cpac.washington.edu> tom at yang.cpac.washington.edu (Tom May) writes:
>If I do this:
>	char *p1, *p2;
>	p1 = malloc (100);
>	p2 = realloc (p1, 200);
>and malloc() returns non-NULL, but realloc() returns NULL, is the memory
>pointed to by p1 still allocated?

Section 4.10.3.4 (the realloc function), page 156, lines 23-24:

	"If the space cannot be allocated, the object pointed to by ptr
	[the first parameter] is unchanged."

Dave Prosser	...not an official X3J11 answer...



More information about the Comp.lang.c mailing list