home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22328 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.9 KB

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