delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/17/10:15:39

Date: Sun, 17 Oct 1999 14:12:49 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Mohamed Saad <bazramit AT yahoo DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: exit() makes my program crash!!!! (The solution)
In-Reply-To: <19991014153345.382.rocketmail@web122.yahoomail.com>
Message-ID: <Pine.SUN.3.91.991017141156.25053J-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Thu, 14 Oct 1999, Mohamed Saad wrote:

> i had a look
> on the source code of exit() and i found it sets the
> mode back to text mode before calling _exit()!

You didn't look deep enough under the hood.  The exit code calls the 
`setmode' function to set the console device to the text (as opposed to 
binary) mode, but that has nothing to do with switching the VGA to the 
text mode.  The text/binary mode of the console has to do with 
translation of CR-LF pairs into a single Newline character during DOS 
I/O, it has nothing to do with the VGA mode.

> P.S. I have discovered that i do not free() some
> malloc'ed() memory! may this be the reason?

No.  All memory is released automatically when the program exits.

> P.P.S. before i forget, can i combine new, delete, and
> realloc??

This is a very bad idea.  In C++ programs you should use new and
delete, not malloc and its friends.

- Raw text -


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