Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2000:
[Freeciv-Dev] Re: TODO
Home

[Freeciv-Dev] Re: TODO

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxxxx
Cc: Jules Bean <jules@xxxxxxxxxxxxxxxxxxxxxxxxx>, Erik Sigra <freeciv@xxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: TODO
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: 22 Sep 2000 14:08:11 +0200

Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxxxx> writes:

> On Fri, Sep 22, 2000 at 10:56:58AM +0100, Jules Bean wrote:

> > struct locus make_locus(int x,int y) {
> >   struct locus l;
> >   l.x=x; l.y=y;
> >   return l;
> > }
> 
> AFAIK this is wrong. The variable l is created on the stack which is
> destroyed at the return. You have to do return a newly allocated
> part of memory. Using this you will get some problems with
> bookkeeping since C has no GC.

You're confused.  This is no more wrong than

int gimme_five (void)
{
  int i = 5;
  return i;
}

is wrong.  (The fact structures usually won't fit in the places where
a compiler usually hides other variables is not important from out
point of view.)

-- 
Big Gaute (not to be confused with LG)
I'm having a BIG BANG THEORY!!



[Prev in Thread] Current Thread [Next in Thread]