delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/22/17:53:15

From: "Chaos" <chengin AT alpha DOT net DOT pl>
Newsgroups: comp.os.msdos.djgpp
Subject: freeing memory and exiting (safely)
Date: Wed, 22 Dec 1999 16:45:52 +0100
Organization: Chaos Engine
Lines: 31
Message-ID: <83ril4$4ua$1@portraits.wsisiz.edu.pl>
NNTP-Posting-Host: pd230.warszawa.ppp.tpnet.pl
X-Trace: portraits.wsisiz.edu.pl 945901028 5066 212.160.55.230 (22 Dec 1999 22:17:08 GMT)
X-Complaints-To: abuse AT news DOT wsisiz DOT edu DOT pl
NNTP-Posting-Date: 22 Dec 1999 22:17:08 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

Hi there.

In my program, I use several buffers which are dynamically allocated
(malloc) and also freed during run time (free). For every buffer I'm setting
condition which looks close to this:

background=malloc(BACKGROUND_BUF_SIZE);
if(!background)
   {
    fprintf(stderr,"Can't allocate memory for buffor ''background''! \n");
    return 1;
   }

My question is that if the prog reaches that "return 1" (synonim for error)
does those buffers will be safely deallocated?
Generaly I'm interested about knowing is there any function that frees all
previously allocated memory without asking me what buffer exist or not. I
just want to exit safe from the program and deallocate it's memory without
blocking it in later use.
I know I want something very weird ;-)

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