Am 22.08.2012 09:44, schrieb Graeme Gill: > Lukas Geyer wrote: >> The address space is expanded immediately but physical memory pages are >> assigned at the moment the memory is accessed; either never, always or >> at kernels discretion, depending on the implemented overcommit strategy [1]. > > Right, but malloc will return NULL if the address space is not available. > This is less likely on a 64 bit system, but quite possible on a 32 bit system. > Whether you can actually use that memory is a different question, > but it's certain that you can't use it if the address is NULL!
Of course, but one has to be aware that the nullptr validation serves a different purpose then (address space availability validation, not memory availability validation) and thus can be used as a fail condition only, because the success condition has (theoretically) no practical value, as you don't know wheter you can actually use the memory provided, or not. int *value = new int; if (value != nullptr) *value = 42; // Bang, you are dead. _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest