home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!amdahl!rtech!sgiblab!sdd.hp.com!cs.utexas.edu!geraldo.cc.utexas.edu!gargravarr.cc.utexas.edu!chrisj
- From: Chris Johnson <chrisj@emx.cc.utexas.edu>
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: A malloc() built upon sbrk() on a Mac?
- Date: 27 Jan 1993 20:21:31 GMT
- Organization: University of Texas at Austin Computation Center
- Lines: 30
- Distribution: world
- Message-ID: <1k6qsbINNkpd@geraldo.cc.utexas.edu>
- References: <BOORTZ.93Jan27115728@dunlop.sics.se>
- NNTP-Posting-Host: gargravarr.cc.utexas.edu
- X-UserAgent: Nuntius v1.1.1d17
- X-XXMessage-ID: <A78C48ABA502BE1F@gargravarr.cc.utexas.edu>
- X-XXDate: Wed, 27 Jan 93 20:11:55 GMT
-
- In article <1993Jan27.164137.29669@kth.se> Jon W!tte,
- d88-jwa@hemul.nada.kth.se writes:
- >>3. Implement sbrk() with SetPtrSize() on this memory area
- >> and let malloc() take memory from this area.
- >
- >Bad Idea. SetPtrSize may move the block, which invalidates all
- >your present pointers into it. Not to mention there might be another
- >locked block (ptr or locked handle that isn!t movehhid) in its way.
-
- SetPtrSize can't move its target block because it only operates on
- non-relocatable blocks (blocks allocated with NewPtr). SetHandleSize,
- on the other hand, works on relocatable blocks (blocks allocated with
- NewHandle), so it can move its target block if adjacent memory isn't
- available and the target block is unlocked at the time.
-
- SetPtrSize, of course, frequently fails because non-relocatable blocks
- are allocated as low in the heap as possible (to minimize fragmentation)
- and are usually immediately surrounded by other non-relocatable blocks.
- But, on the occasions SetPtrSize does work, you *never* have to worry
- about the target block moving.
-
- ----Chris
-
- Chris Johnson
-
- Internet: chrisj@emx.cc.utexas.edu
- UUCP: {husc6|uunet}!cs.utexas.edu!ut-emx!chrisj
- BITNET: chrisj@utxvm.bitnet
- CompuServe: >INTERNET:chrisj@emx.cc.utexas.edu
- AppleLink: chrisj@emx.cc.utexas.edu@internet#
-