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