Date: Sat, 05 Jan 2008 14:50:37 +0100 From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> To: Robert Watson <rwatson@FreeBSD.org> Cc: Poul-Henning Kamp <phk@phk.freebsd.dk>, freebsd-current@freebsd.org, Jason Evans <jasone@freebsd.org>, Igor Mozolevsky <igor@hybrid-lab.co.uk> Subject: Re: sbrk(2) broken Message-ID: <86odc08jpu.fsf@ds4.des.no> In-Reply-To: <20080104132310.X77222@fledge.watson.org> (Robert Watson's message of "Fri\, 4 Jan 2008 13\:24\:28 %2B0000 \(GMT\)") References: <86myrlahee.fsf@ds4.des.no> <5647.1199451237@critter.freebsd.dk> <a2b6592c0801040503j650046f5k73895b5b0c84025d@mail.gmail.com> <86abnlag4t.fsf@ds4.des.no> <20080104132310.X77222@fledge.watson.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Robert Watson <rwatson@FreeBSD.org> writes: > Another aspect of the problem is that applications have come to depend > in malloc(3) returning NULL when memory is getting tight [...] I don't do that any more. Unless the program I'm writing is intended to run for a long time and can gracefully handle an out-of-memory situation (such as denying client requests until the situation improves), I write malloc() wrappers which zero the allocated region before returning to the caller, to force a SIGSEGV and spare the caller from having to check the return value. I sometimes also allocate a little bit extra and stick a magic signature and an allocation length in there so my free() wrapper can check for bugs and zero the allocated memory before freeing it. I wouldn't need any of this if my code only ran on FreeBSD, but most of my $DAYTIME_JOB code these days runs on Linux first and FreeBSD second. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86odc08jpu.fsf>