Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Jul 2003 00:13:28 +0200 (CEST)
From:      Alban Hertroys <dalroi@solfertje.student.utwente.nl>
To:        Pete French <pfrench@firstcallgroup.co.uk>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: malloc does not return null when out of memory
Message-ID:  <20030725221644.21516376@solfertje.student.utwente.nl>
In-Reply-To: <E19fgYM-0007SV-00@mailhost.firstcallgroup.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On 24 Jul, Pete French punched keys in this particular order:
> Its not bogus - the trouble is that you cant tell at the time malloc returns
> whether the pointer will be useable or not. You only find that out when
> you try and use it, and whether theres any space or not depends oon what
> else may have munched up (or released) memory between you making the call
> to malloc() and actually writing to the location returned.

This looks similar to the problem with mktemp(). Maybe it is possible to
solve this in a similar way? For example, by allocating memory and
filling it in the same call?

That probably would mean that all the software should switch to a new
way of allocating memory, but it's a start...

-- 

Alban Hertroys                              http://solfertje.student.utwente.nl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                This person has performed an illegal operation
                and will be shot down.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030725221644.21516376>