home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / linux / 17443 < prev    next >
Encoding:
Internet Message Format  |  1992-11-21  |  1.4 KB

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