[ale] OT: C not C++ Question

Chuck Huber chuck at cehuber.org
Mon Dec 30 09:00:54 EST 2002


On Sun, Dec 29, 2002 at 10:40:15PM -0500, cfowler wrote:
> 
> > 
> > 	You might look into Henry Spencer's alloca() implementation that uses
> > malloc.  The gcc alloca() allocs mem from the stack, which is reclaimed
> > automatically when the function returns from the function that uses it. 
> > Henry's alloca() uses malloc, but keeps the blocks in a linked list. 
> > Calling alloca(0) in the "top loop" of your program performs garbage
> > collection.
> > 
> >
> 
> Would it protect the programmer in this case:
> 
> String *tmp = String_new("Hello World!\r\r");
> tmp = String_new("Hello Again!\r\n");
> 
> Since tmp got a new pointer the original pointer is forever
> lost.  In Java that memory will just be reaped by GC but in C
> it is lost until exit() is called :)

Chris,  How much more work are you going to put into being lazy?

Enjoy,
    - Chuck

-- 
"The purpose of encryption is to protect good people
from bad people, not to protect bad people from the government."
     Scott McNealy, CEO Sun Microsystems
"The best way for government to control people is to remain in
   a constant threat of war." ---Karl Marx
(18 USC 242), which applies to government agents overstepping their
authority:
  "Whoever, under color of any law, statute, ordinance, regulation,
  or custom, willfully subjects any person in any State, Territory,
  or District to the deprivation of any rights, privileges, or
  immunities secured or protected by the Constitution or laws of
  the United States, . . . shall be fined under this title or
  imprisoned not more than one year, or both . . ."

 PGP signature




More information about the Ale mailing list