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