delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/04/20:39:51

Date: Wed, 4 Feb 1998 17:38:37 -0800 (PST)
Message-Id: <199802050138.RAA05569@adit.ap.net>
Mime-Version: 1.0
To: djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Freeing static vars

At 05:07  2/4/1998 +0200, S. M. Halloran wrote:
>> 
>> Rylan wrote:
>> > > Is there anyway to free static variables under DJGPP when they have
>> > > outlived their usefulness?
>> > 
>> > Of course not. If there were, this would mean you could *dynamically*
>> > change the size of that variable (to zero). But 'dynamic' is the exact
>> > contradiction of 'static'. Depending on the size of that variable,
>> > this is either no problem at all, or you should have used a dynamic
>> > variable in the first place.
>> 
>> Sorry, stupid question. I wish to apologize to the group for wasting
>> its time.
As a somewhat interesting sidelight on this issue that has nothing to do
with the current discussion, this can be possible. K&R I has, as an example,
an implementation of `malloc' (which they call `alloc') and `free'. Since
the system works by keeping a free list, it is possible to add an arbitrary
region of memory (like a static array) to it. In fact, one of the exercises
is to write a routine (they call it `bfree') that does just that.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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