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