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

  1. Path: sparky!uunet!paladin.american.edu!howland.reston.ans.net!wupost!cs.utexas.edu!unisql!wrat
  2. From: wrat@unisql.UUCP (wharfie)
  3. Newsgroups: comp.unix.aix
  4. Subject: Re: malloc(0) fails on AIX and nowhere else I could find ...
  5. Message-ID: <4512@unisql.UUCP>
  6. Date: 9 Jan 93 01:17:47 GMT
  7. References: <C0HCs4.Eoy@axion.bt.co.uk> <1ikdebINN6qv@CS.UTK.EDU> <C0JvG9.1HBs@austin.ibm.com>
  8. Organization: UniSQL, Inc., Austin, Texas, USA
  9. Lines: 14
  10.  
  11. In article <C0JvG9.1HBs@austin.ibm.com> dcm@codesmith.austin.ibm.com (Craig Miller - dcm@austin.ibm.com) writes:
  12. >those who support malloc(0):    ptr = malloc(length);
  13. >those who don't:        ptr = (length == 0) ? NULL : malloc(length);
  14. >
  15. >Right?  And the second case *always* works, regardless of whether the
  16. >local implementation of malloc supports malloc(0) or not.  Right?
  17.  
  18.     Nope.  Most code that expects malloc(0) to return a pointer to
  19. 0 bytes does something like
  20.  
  21.     if (!(ptr=malloc(foo))) goto NO_MEMORY;
  22.  
  23.  
  24.  
  25.