Re: Return value of malloc(0)



On Thu, Jun 29, 2006 at 11:44:23AM -0400, Pat Lashley wrote:
> No, our implementation is NOT legal. We always return the SAME value. To
> be legal, we should not return that value again unless it has been
> free()-ed.

It is legal due to brain damaged definition of implementation defined
behaviour, but it violates the spirit of the standard :-)

Perhaps I'm misunderstanding the 'implementation defined behavior' choices in the standard. I thought that it could either 1) Return NULL; or 2) Behave as though it returned a 'minimum allocation' (which cannot be legally de-referenced). But if it did actually perform a 'minimum allocation'; wouldn't it have to return a different value every time to maintain the free() semantics?




-Pat _______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Is C99 the final C? (some suggestions)
    ... This would violate the division between preprocessor and compiler too ... much (the preprocessor would have to understand quite a lot of C semantics). ... ...This is legal C (as per the Standard), but it overflows the stack on ...
    (comp.lang.c)
  • Re: Countable models of ZFC
    ... When I say "M is a set", I don't mean it's a set living in some model, ... If so, WHAT IS THE DEFINITION (of standard, ... the WHOLE of first-order semantics with it. ... you'd best at LEAST concede that M was a proper class. ...
    (sci.logic)
  • Re: mutex question
    ... Do you agree or disagree with my usage of sufficient, which has nothing much to do with your 'sufficient for externally observable reads and writes', by which I think you mean "triggers a memory read or write", without placing much in the way of semantics on those reads and writes. ... it is *not* necessary nor is it sufficient to use volatile on variables shared between threads.' ... C++ standard. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Turing completeness of the functional paradigm?
    ... > for second-order languages. ... There is one standard semantics that people mean ... when they talk about second-order logic. ... But if you want to use the Henkin semantics, ...
    (sci.logic)
  • Re: Return value of malloc(0)
    ... choices in the standard. ... or 2) Behave as though it returned a 'minimum allocation' (which ... the returned pointer shall not be used to access an object. ... "minimum" is zero, then using a sentinel value works. ...
    (freebsd-hackers)