www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/28/13:41:30

Date: Sat, 28 Mar 1998 10:39:50 -0800 (PST)
Message-Id: <199803281839.KAA16505@adit.ap.net>
Mime-Version: 1.0
To: edc AT arches DOT uga DOT edu (Edward Cashin), djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: djgpp malloc and freeing memory on exit

At 04:25  3/28/1998 GMT, Edward Cashin wrote:
>Hello.  I hear continually that it is good 
>programming practice to have a call to free for every call to 
>malloc.  It certainly makes sense to free memory once it will 
>no longer be used in the program.  However, there will be cases 
>in which dynamically-allocated memory doesn't need to be freed 
>until the program exits.
>
>I have not had trouble so far exiting without freeing memory
>allocated with a call to malloc, and AFAIK that is because W95
>has been nice, freeing up all the memory after my program exits.
>I could be wrong: maybe djgpp's exit routines take care of it.

They do. The only things you *need* to free yourself (AFAIK) are selectors
and memory allocated directly from `__dpmi' functions.

The only part W95/DOS has to free is the initial space into which it loaded
the real-mode stub, and it's impossible to free that yourself. You'll have
to trust it here. :)

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019