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