Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108)
Home

[Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Dec 2001 19:44:17 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Dec 13, 2001 at 06:39:36PM +0000, Gregory Berkolaiko wrote:
>  --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> 
> > Your patch has code like
> > +  generate_warmap(NULL, x, y, NULL);
> > +  boatdist = get_warmap_sea(NULL, x, y);
> > 
> > if this code uses a non-global warmap (which is the goal) it has to be
> > changed to:
> > +  generate_warmap(&wm, x, y, NULL);
> > +  boatdist = get_warmap_sea(&wm, x, y);
> > 
> > If you change your patch so that the code looks like
> > +  pwm = generate_warmap(x, y, NULL, 1);
> > +  boatdist = get_warmap_sea(pwm, x, y);
> > 
> > that you only have to change the "1" to use a non-global warmap. The
> > access function calls (get_warmap_sea and get_warmap_land) will remain
> > unchanged.
> 
> Aha, I undertand now.  One very good argument in favour of not doing it
> this way was given by Jason.  I can only add a stupid argument: if you
> allocate the memory yourself, you are more likely to remember to free it
> (btw you forgot that to use non-local warmap, you have to do more than
> change 0 to 1, you have to free pwm).

Than add a free call unconditionally and do something like this:

void free_warmap(...pwm)
{
   if(pwm==&global_warmap) return;
   do real stuff
}

However for placing such free_warmap calls you have to know the
lifetime of the generated warmap.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Only one human captain has ever survived battle with the Minbari
  fleet. He is behind me. You are in front of me. If you value your 
  lives, be somewhere else."
    -- Ambassador Delenn, "Severed Dreams," Babylon 5


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