Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] Re: (PR#8522) historian agent copies units badly
Home

[Freeciv-Dev] Re: (PR#8522) historian agent copies units badly

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#8522) historian agent copies units badly
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Fri, 16 Apr 2004 01:09:51 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8522 >

On Thu, Apr 15, 2004 at 03:00:37PM -0700, Jason Short wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=8522 >
> 
> The historian "agent" copies units by doing:
> 
>    *pold_unit = *punit;
> 
> but this isn't safe since some of the fields of the unit are pointers to 
> allocated memory.  If punit is deallocated this will give memory 
> corruption when pold_unit is accessed.
> 
> The only alternative is a copy_unit function:

I agree but we should name this unit_clone.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Python is executable pseudocode. Perl is executable line noise"
    -- Bruce Eckel




[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#8522) historian agent copies units badly, Raimar Falke <=