home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!wirzeniu
- From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
- Newsgroups: comp.os.linux
- Subject: Re: malloc (0) ( Re: function-->macro bugs.)
- Message-ID: <1992Nov21.124529.10725@klaava.Helsinki.FI>
- Date: 21 Nov 92 12:45:29 GMT
- References: <By0ows.95I@news.cso.uiuc.edu> <1992Nov21.000241.9744@klaava.Helsinki.FI> <1992Nov21.102153.15162@serval.net.wsu.edu>
- Organization: University of Helsinki
- Lines: 26
-
- hlu@yoda.eecs.wsu.edu (H.J. Lu) writes:
- >1. malloc (0) returns NULL is ok under POSIX.
-
- Under ANSI/ISO C too. OTOH, malloc(0) != NULL are ok by everybody as
- well.
-
- >If you can come up with a better idea to deal with
- >
- > p = malloc (len); /* len may be 0. */
- > if (!p) fatal ("Out of memory");
- >
- >I'd like to hear from you.
-
- There are programs which assume that malloc(0)==NULL, and programs
- which assume malloc(0)!=NULL. We can't support both types at the same
- time without some kinds of hacks, something will surely break.
-
- I have no problems with the current scheme (except for some naming
- choices, I'd prefer __MALLOC_0_IS_NON_NULL instead of NO_FIX_MALLOC).
- Fixing programs that try to substitute their own malloc shouldn't be
- that hard. We'll never achieve total compatibility with all current
- source code anyway.
-
- --
- Lars.Wirzenius@helsinki.fi (finger wirzeniu@klaava.helsinki.fi)
- MS-DOS, you can't live with it, you can live without it.
-