[Freeciv-Dev] Re: TODO
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Fri, Sep 22, 2000 at 11:49:19AM +0100, 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.
Till now I thought returning structures in C was an extension of gcc. It
looks like this was a false assumption. Is it possible that this construct
wasn't allowed in 1993?
Thanks for clarification.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Many of my assistants were fans of Tolkien, who wrote 'Lord of the Rings'
and a number of other children's stories for adults. The first character
alphabet that was programmed for my plotter was Elvish rather than Latin."
-- from SAIs "life as a computer for a quarter of a century"
- [Freeciv-Dev] Re: TODO, (continued)
- [Freeciv-Dev] Re: TODO, Erik Sigra, 2000/09/21
- [Freeciv-Dev] Re: TODO, Falk Hueffner, 2000/09/22
- [Freeciv-Dev] Re: TODO, Erik Sigra, 2000/09/22
- [Freeciv-Dev] Re: TODO, Jules Bean, 2000/09/22
- [Freeciv-Dev] Re: TODO, Raimar Falke, 2000/09/22
- [Freeciv-Dev] Re: TODO, Jules Bean, 2000/09/22
- [Freeciv-Dev] Re: TODO, Daniel Sjölie, 2000/09/22
- [Freeciv-Dev] Re: TODO, Jeff Mallatt, 2000/09/22
- [Freeciv-Dev] Re: TODO, Jules Bean, 2000/09/22
- [Freeciv-Dev] Re: TODO, Jeff Mallatt, 2000/09/22
- [Freeciv-Dev] Re: TODO,
Raimar Falke <=
- [Freeciv-Dev] Re: TODO, Daniel Sjölie, 2000/09/22
- [Freeciv-Dev] Re: TODO, Gaute B Strokkenes, 2000/09/22
- [Freeciv-Dev] Re: TODO, Greg Wooledge, 2000/09/22
- [Freeciv-Dev] Re: TODO, Gaute B Strokkenes, 2000/09/22
- [Freeciv-Dev] Re: TODO, Erik Sigra, 2000/09/22
- [Freeciv-Dev] Re: -ansi -pedantic, was Re: TODO, David Pfitzner, 2000/09/22
[Freeciv-Dev] Re: TODO, David Pfitzner, 2000/09/24
|
|