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: Jules Bean <jules@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: TODO
From: Daniel Sjölie <deepone@xxxxxxxxxx>
Date: Fri, 22 Sep 2000 12:56:46 +0200

On 2000-09-22 11:49:19, Jules Bean wrote:
> On Fri, Sep 22, 2000 at 12:45:45PM +0200, Raimar Falke wrote:
> > On Fri, Sep 22, 2000 at 10:56:58AM +0100, Jules Bean wrote:
> > > Instead use a 'constructor' function
> > > 
> > > 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.
> 
> Nope.
> 
> The above will make another copy of 'l' and return that.
> 
> I'm not returning a pointer to l, I'm returning l itself, which is a
> copying operation.  At no point do I use pointers, so I cannot trip
> over destroyed memory errors.

Doh!
Didn't catch that one... ;p

/Daniel

-- 
Now take a deep breath, smile and don't take life so seriously... :)



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