home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / c / 12472 < prev    next >
Encoding:
Text File  |  1992-08-17  |  1.5 KB  |  41 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Subject: Re: How many malloc's can I use?
  5. Message-ID: <9223121.15315@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <1992Aug17.181615.11905@proxxi.se>
  9. Date: Tue, 18 Aug 1992 11:27:02 GMT
  10. Lines: 29
  11.  
  12. elias@proxxi.se (Elias M}rtensson (proxxi)) writes:
  13.  
  14. >Does ANSI C specify the maximum number of malloc calls that can safely
  15. >be made? Can I do a couple of thousand malloc's and still count on
  16. >that everything will work fine? I am not interested in any
  17. >descriptions of the MS-DOS limitations or anything like that. I just
  18. >want to know what ANSI C says.
  19. >
  20. >And does ANSI C specify that largest block of memory that can be
  21. >malloc'ed?
  22.  
  23. I am fairly sure that the following would be a ANSI-conforming implementation
  24. for malloc:
  25.  
  26. void *malloc(size_t size) {
  27.     errno = E_THIS_SYSTEM_DOESNT_HAVE_DYNAMIC_ALLOCATION;
  28.     return 0;
  29. }
  30.  
  31. In other words, I fairly ANSI does not make any guarantees as to the amount
  32. of memory that can be allocated with malloc. The only constraint is that if
  33. for whatever reason it cannot allocate the desired amount, it must return
  34. a null pointer after setting errno to an appropriate value.
  35.  
  36. -- 
  37. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  38. This .signature VIRUS is a self-referential statement that is true - but 
  39. you will only be able to consistently believe it if you copy it to your own
  40. .signature file!
  41.