home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / amiga / programm / 18145 < prev    next >
Encoding:
Text File  |  1993-01-05  |  1.4 KB  |  31 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!math.fu-berlin.de!news.th-darmstadt.de!rbg.informatik.th-darmstadt.de!misar
  3. From: misar@rbg.informatik.th-darmstadt.de (Walter Misar)
  4. Subject: Re: How to allocate memory nicely?
  5. Sender: news@news.th-darmstadt.de (The News System)
  6. Message-ID: <1993Jan5.094153@rbg.informatik.th-darmstadt.de>
  7. Date: Tue, 5 Jan 1993 08:41:53 GMT
  8. References:  <1iasdiINN754@uniwa.uwa.edu.au>
  9. Nntp-Posting-Host: rbhp69.rbg.informatik.th-darmstadt.de
  10. Organization: TH Darmstadt
  11. Lines: 18
  12.  
  13. In article <1iasdiINN754@uniwa.uwa.edu.au>, gujn@uniwa.uwa.edu.au (Jeremy Nelson) writes:
  14. > This is probably a simple question for the programmers, so reply by news
  15. > or mail as you see fit...
  16. > How should I allocate memory for short strings of, say, 15 characters or
  17. > so without unnecessarily fragmenting the memory?   Should I request 1k
  18. > chunks and doll it out as necessary?  And how small is too small?
  19. > Help from the experienced would be appreciated.  Thanks. (I'm talking 
  20. > C of course. :)
  21.  
  22. I would just use malloc() or calloc(). On most systems this works just as you
  23. suggested, that is, if you request 15 bytes, it actually gets a larger page
  24. of memory from the OS and saves the rest for further calls of malloc().
  25.  
  26. -- 
  27. Walter Misar                        It is impossible to enjoy idling thoroughly
  28. misar@rbg.informatik.th-darmstadt.de       unless one has plenty of work to do.
  29.