From mboxrd@z Thu Jan 1 00:00:00 1970 From: norman@oclsc.org (Norman Wilson) Date: Fri, 11 Sep 2015 11:41:23 -0400 Subject: [TUHS] Did realloc ever zero the new memory? Message-ID: <1441986088.9291.for-standards-violators@oclsc.org> I've used realloc a lot, and never run into bugs. Maybe I've just been lucky, or maybe it's that I probably didn't use it that much until the latter 1980s, and then more with pukka Doug malloc code than with the stuff floating around elsewhere. Never mind that sometime around 1995 I found a subtle bug in the pukka Doug malloc (not realloc): arena blew up badly when presented with a certain pattern of alternating small and large allocs and frees, produced by a pukka Brian awk regression test. I had a lot of (genuine) fun tracking that down, writing some low-level tools to extract the malloc and free calls and sizes and then a simulator in (what else?) awk to test different fixes. Oh, for the days when UNIX was that simple. I've never heard before of a belief that the new memory belonging to realloc is always cleared, except in conjunction with the utterly- mistaken belief that that's true of malloc as well. I don't think it was ever promised to be true, though it was probably true by accident just often enough (just as often as with malloc) to fool the careless. Norman Wilson Toronto ON