Date: Mon, 13 Jun 2005 23:16:49 +0200 From: des@des.no (=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=) To: Mike Hunter <mhunter@ack.berkeley.edu> Cc: freebsd-hackers@freebsd.org Subject: Re: unitialized memory is all zeros...why not garbage instead? Message-ID: <868y1eufcu.fsf@xps.des.no> In-Reply-To: <20050613193150.GA75218@malcolm.berkeley.edu> (Mike Hunter's message of "Mon, 13 Jun 2005 12:31:50 -0700") References: <20050610224058.GA11336@malcolm.berkeley.edu> <86vf4lb110.fsf@xps.des.no> <20050613193150.GA75218@malcolm.berkeley.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
Mike Hunter <mhunter@ack.berkeley.edu> writes: > Is the pre-zeroing of malloc'd memory documented somewhere? By my reading > of the malloc manapge... malloc() does not pre-zero memory, but it hands you memory which has been pre-zeroed by the kernel unless you've used it before. Your test program makes only one malloc() call, so you get memory that has never been used before. > ...it seems like it's saying that malloc (as opposed to calloc) is NOT > pre-zeroed. Is there a different document I should be reading? No, but nowhere in the standard does it say that memory allocated with malloc() must contain non-zero garbage. If that is what you want, though, read the TUNING section in the malloc(3) man page. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?868y1eufcu.fsf>