home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22334 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.8 KB  |  52 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!agate!spool.mu.edu!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!sics.se!boortz
  3. From: boortz@sics.se (Kent Boortz)
  4. Subject: A malloc() built upon sbrk() on a Mac?
  5. Message-ID: <BOORTZ.93Jan27115728@dunlop.sics.se>
  6. Sender: news@sics.se
  7. Organization: Swedish Institute of Computer Science, Kista
  8. Distribution: comp
  9. Date: Wed, 27 Jan 1993 10:57:28 GMT
  10. Lines: 40
  11.  
  12.  
  13.  
  14. I have a malloc() replacement that I want to port to Mac.
  15. It assumes a continuous memory area and a upper bound
  16. moved by the Unix sbrk() call.
  17.  
  18. What I came to think of is this:
  19.  
  20. 1.    Allocate a fixed stack space (this is the normal way
  21.     on a Mac, isn't it?)
  22. 2.    Allocate with NewPtr() memory at the lowest address
  23.     in the application heap. This will be immediately
  24.     after the stack space.
  25. 3.    Implement sbrk() with SetPtrSize() on this memory area
  26.     and let malloc() take memory from this area.
  27. 4.    If SetPtrSize() fails I do a MaxApplZone() and try
  28.     again.
  29.  
  30. This way my "Unix" memory handling will grow from low application
  31. heap address to high and normal mac allocation will grow from
  32. high memory address to low. The collision of memory will still
  33. be handled by the memory manager.
  34.  
  35. My problem is to do (2) because normally I can't tell the mac memory 
  36. manager where I want to take memory. A solution to that could be:
  37.  
  38.         AllocMem = NewPtr(MaxMem(&any));
  39.         SetPtrSize(AllocMem,size_wanted);
  40.  
  41. Any thought about this? Is there other ways of doing what I want?
  42.  
  43. Is there any way of doing mmap() on a mac? I have some large allocated
  44. blocks that sometimes has to grow, and many small blocks. This sometimes
  45. lead to big holes in the malloc memory area. If I could place these blocks
  46. sparse they could grow and shrink without moving.
  47.  
  48. /kgb
  49. --
  50. Kent Boortz
  51. boortz@sics.se
  52.