home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14824 < prev    next >
Encoding:
Text File  |  1992-09-01  |  2.0 KB  |  41 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!wupost!usc!rpi!batcomputer!snake.tc.cornell.edu!reed
  3. From: reed@snake.tc.cornell.edu (Michael G. Reed)
  4. Subject: Re: Hacking Think_C Malloc, need big free!
  5. Message-ID: <1992Sep1.120652.10990@tc.cornell.edu>
  6. Followup-To: comp.sys.mac.programmer
  7. Sender: news@tc.cornell.edu
  8. Nntp-Posting-Host: snake.tc.cornell.edu
  9. Reply-To: reed@Theory.TC.Cornell.EDU
  10. Organization: Cornell National Supercomputing Facility
  11. References:  <1992Aug31.223642.1858@bnr.ca>
  12. Date: Tue, 1 Sep 1992 12:06:52 GMT
  13. Lines: 26
  14.  
  15. In article <1992Aug31.223642.1858@bnr.ca>, brunner@crchh447.bnr.ca (James Brunner) writes:
  16. |> Howdy, I'm working on a kludge where I am combining several UNIX utilities.
  17. |> Each of these allocates memory and it gets freed automatically at exit(0).
  18. |> I would like to be able to free all malloc-allocated memory between calls
  19. |> to these utils.  I've looked at alloc.c but it's all in asm and hard to read.
  20. |> 
  21. |> How can the library be modified to add a free_all routine?
  22.  
  23. If I remember correctly, ThinkC's malloc (and calloc for that matter) are 
  24. simply mapped into calls to the memory manager call NewPtr.  Therefore, the
  25. only way to "free-all" would be to free everything in the heap (which would
  26. be VERY bad, because you would free your code as well...).  I'm not sure how
  27. to do it (I don't have IMs here at work yet), and for that matter, I'm not
  28. sure this would even work, but I think you could create a new heap, set your
  29. current heap (zone?) into that heap, do all your allocation and then simply
  30. destroy the heap for your "free-all".  Sound plausible?
  31.  
  32. -Michael
  33.  
  34. -----------------------------------------------------------------------------
  35. Michael G. Reed                                  (reed@Theory.TC.Cornell.edu)
  36. Cornell National Supercomputing Facility                       (607)/254-8806
  37. -----------------------------------------------------------------------------
  38.         Why be normal, it's boring; and boring people should be shot.
  39.  
  40. Note:  These are not the views of my employer (and probably not mine either).
  41.