H
Herbert Rosenau
Correct, it may. It may _not_, however, fail because the implementation
chose to hand the memory freed back to the OS. The standard forbids
this, meaning that a failure in a subsequent allocation (of the same or
lesser amount of memory) is at best a QoI issue, at worst a bug, whereas
handing the memory back to the OS such that the OS might re-use it is not
merely a QoI issue or a bug, but a non-conforming behaviour.
No, the standard requires only explicity that the block is not blocked
from further allocation. It does not forbid that free gives the block
back to the OS because that would explicity forbid that free is
nothing than only a wrapper to an OS API that does exactly that. So
where in the standard is mentioned that the whole malloc family is not
only wrappers to OS API? Chapter and verse, please.
Not quite the point, though, is it? It knows the memory _will_ be
available, whereas if the memory is handed off to the OS for use outside
the scope of the program, the guarantee is violated.
There is no guarantee in the standard that freed memory is really
available again on next allocation of the same program. There is only
a requirement that the freed block is available for further allocation
- saying that the block is now unblocked. free() unblocks and the next
request allocs it, so further allocation is done.
--
Tschau/Bye
Herbert
Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2R Deutsch ist da!