home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / aix / 13170 < prev    next >
Encoding:
Internet Message Format  |  1993-01-10  |  1.3 KB

  1. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!cleveland.Freenet.Edu!cq377
  2. From: cq377@cleveland.Freenet.Edu (David C. Williss)
  3. Newsgroups: comp.unix.aix
  4. Subject: Re: malloc(0) fails on AIX and nowhere else I could find ...
  5. Date: 10 Jan 1993 06:30:27 GMT
  6. Organization: Case Western Reserve University, Cleveland, OH (USA)
  7. Lines: 17
  8. Message-ID: <1iofq3INN4v0@usenet.INS.CWRU.Edu>
  9. References: <C0LnII.pGK@austin.ibm.com> <1ikdebINN6qv@CS.UTK.EDU> <C0JvG9.1HBs@austin.ibm.com> <4512@unisql.UUCP>
  10. Reply-To: cq377@cleveland.Freenet.Edu (David C. Williss)
  11. NNTP-Posting-Host: thor.ins.cwru.edu
  12.  
  13.  
  14. A few words about malloc(0)...
  15.  
  16. I have been told that according to ANSI (I havn't read it myslef), that
  17. no matter what malloc(0) returns, you should be able to free() and
  18. realloc() it.  In otherwords, even if malloc(0) returns NULL, it's OK.
  19.  
  20. It does cause unexpected behaviour if you're not expecting it though.
  21. I've spent many hours tracking down "Out of memory" errors that were
  22. caused by myself or somebody else trying to malloc 0 bytes then
  23. returning an out of memory error just because malloc returned NULL.
  24.  
  25. -- 
  26.         -Dave Williss
  27. ---------------------------------------------------------------------------
  28. Standards are great!  Everybody should have one of their own!
  29. The opinions stated above are Mine!  All Mine!  You can't have them.
  30.