www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/28/17:34:48

From: "Chaos" <chengin AT alpha DOT net DOT pl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: freeing memory and exiting (safely)
Date: Sun, 26 Dec 1999 15:29:51 +0100
Organization: Chaos Engine
Lines: 43
Message-ID: <848onp$rvo$1@portraits.wsisiz.edu.pl>
References: <199912230049 DOT SAA09717 AT lakdiva DOT slt DOT lk>
NNTP-Posting-Host: pe191.warszawa.ppp.tpnet.pl
X-Trace: portraits.wsisiz.edu.pl 946333241 28664 212.160.56.191 (27 Dec 1999 22:20:41 GMT)
X-Complaints-To: abuse AT news DOT wsisiz DOT edu DOT pl
NNTP-Posting-Date: 27 Dec 1999 22:20:41 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.1
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> My question is that if the prog reaches that "return 1" (synonim for
error)
> does those buffers will be safely deallocated?

Hi again Chaos,

When your program terminates execution the OS (cwsdpmi or
Windoze etc) should handle all the deallocation of the allocated
memory used by that program.

Phew! At least I don't have to worry about that one. Thnx.

So if that "return 1 " statement causes your program to terminate
(ie if it's in the main() function) and exit to the OS  then you can
count on all your previously undeallocated memory being freed.

So IMHO say if you allocate a 4M buffer and exit to the OS without
freeing it the OS should free it and all the other memory that you
process consumed.

That's what I wanted exactly to know. Thnx again.

However IMHO it might be nice (at least for aesthetic purposes) to
write a error handling function which in your case would cleanup
the deallocating of previously allocated memory and do other things
like restoring hooked interrupt's etc.

Yeah, it would be nice. Actually I have such function.

> I know I want something very weird ;-)
No way! It's not weird at all.

I was kidding ;-)

Kalum

Take care.
-=| Chaos |=-
e-mail:  chengin AT alpha DOT net DOT pl
              chengin AT polbox DOT com



- Raw text -


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