[TUHS] Did realloc ever zero the new memory?

arnold at skeeve.com arnold at skeeve.com
Fri Sep 11 16:30:36 AEST 2015

> On Thu, Sep 10, 2015 at 4:21 PM, Larry McVoy <lm at mcvoy.com> wrote:
> > Am I the only one that remembers realloc() being buggy on some systems?

Clem Cole <clemc at ccc.com> wrote:

> Amen...   it was rarely useful.   I always found realloc to one of the
> part I could never trust.  I do remember  what you got back from any of the
> malloc calls could vary widely.  Particularly pre-ANSI C and working on
> non-UNIX systems.

I would not say this applies today. The GLIBC realloc is very effective.
The place where I see this is in gawk, which special cases

	a = a b	# concatenate string b onto the end of string a

By using realloc to grow the contents of a and copying b's contents
onto the end I see a huge speedup over the dance of

	char *p malloc(length(a) + length(b))
	copy in a
	copy in b
	free old a
	make a point at new storage


More information about the TUHS mailing list