2 @section @code{realloc}
5 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/realloc.html}
7 Gnulib module: realloc-posix
9 Portability problems fixed by Gnulib:
12 Upon failure, the function does not set @code{errno} to @code{ENOMEM} on
17 Portability problems not fixed by Gnulib:
20 It is not portable to call @code{realloc} with a size of 0. With a
21 NULL pointer argument, this is the same ambiguity as @code{malloc (0)}
22 on whether a unique zero-size object is created. With a non-NULL
23 pointer argument, C99 requires that if @code{realloc (p, 0)} returns
24 @code{NULL} then @code{p} is still valid. Among implementations that
25 obey C99, behavior varies on whether @code{realloc (p, 0)} always
26 fails and leaves @code{p} valid, or usually succeeds and returns a
27 unique zero-size object; either way, a program not suspecting these
28 semantics will leak memory (either the still-valid @code{p}, or the
29 non-NULL return value). Meanwhile, several implementations violate
30 C99, by always calling @code{free (p)} but returning NULL:
34 Extension: Gnulib provides a module @samp{realloc-gnu} that substitutes a
35 @code{realloc} implementation that behaves more like the glibc implementation.