cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/06/00:01:15

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Freeing static vars
Date: Thu, 05 Feb 1998 23:53:43 -0500
Organization: Two pounds of chaos and a pinch of salt.
Lines: 20
Message-ID: <34DA9757.385C@cs.com>
References: <3 DOT 0 DOT 5 DOT 32 DOT 19980205125943 DOT 007b3180 AT math DOT amu DOT edu DOT pl>
NNTP-Posting-Host: ppp219.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Maciej Radziejewski wrote:
> 
> Perhaps it is too obvious to write, but isn't this accomplished in C++
> by defining a local scope and declaring the variables inside it?
> The variables will be destroyed upon leaving the local scope.

Yes, but such variables are automatic, not static.  Use of the term
"static" implies a variable that remains throughout the duration of the
program.  By its very definition, a static variable cannot be deleted or
freed.  However, the data it contains can be modified, so if you define
a static pointer, you could certainly free the memory it points to
(assuming, of course, that you allocated some to begin with).

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "It may be better to be a live jackal|
|       aka Fighteer I       | than a dead lion, but it is better   |
|   mailto:fighteer AT cs DOT com   | still to be a live lion."            |
| http://www.cs.com/fighteer |                - Lazarus Long        |
---------------------------------------------------------------------

- Raw text -


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