[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]
On Sat, Dec 15, 2001 at 01:25:49PM +0000, Gregory Berkolaiko wrote:
> --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> > On Fri, Dec 14, 2001 at 09:40:55PM -0500, Ross W. Wetmore wrote:
> >
> > > Actually, it is not stupid. Forcing the caller to allocate the warmap
> > > and pass it in, keeps the allocation and deallocation at the same
> > point
> > > in the code, and the responsibility clearly assigned.
> >
> > The question is how is the warmap allocated at the caller? Like this:
> >
> > void foobar(...)
> > {
> > int x,y,i;
> > struct warmap my_warmap;
> >
> > or
> >
> > void foobar(...)
> > {
> > int x,y,i;
> > struct warmap *my_warmap=fc_malloc(sizeof(struct warmap));
> >
> > or
> >
> > void foobar(...)
> > {
> > int x,y,i;
> > struct warmap *my_warmap=warmap_get_new_instance();
> >
> > The first two have to be dropped because we agreed that outside code
> > shouldn't know about the struct. So I have no problem if there are:
> >
> > struct warmap *warmap_new();
> > void warmap_init(struct warmap *,struct unit *,struct city *);
>
> You might have noticed that my patch already contains:
> ============================================================
> +/************************************************
> + * Allocate new warmap
> + ************************************************/
> +struct move_cost_map *get_new_warmap(void)
> +{
> + struct move_cost_map *new_warmap;
> + int x;
> +
> + new_warmap = fc_malloc(sizeof(struct move_cost_map));
> + for (x = 0; x < map.xsize; x++) {
> + new_warmap->cost[x]=fc_malloc(map.ysize*sizeof(unsigned char));
> + new_warmap->seacost[x]=fc_malloc(map.ysize*sizeof(unsigned char));
> + new_warmap->vector[x]=fc_malloc(map.ysize*sizeof(unsigned char));
> + }
> + new_warmap->sea_recycle = FALSE;
> + new_warmap->land_recycle = FALSE;
> + return new_warmap;
> +}
> ============================================================
>
> I am glad that you now think it's ok.
Nitpicking: which isn't exported and results in a compile error if
compiled with strict settings like "-Wmissing-prototypes
-Wmissing-declarations -Werror".
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Python 2.0 beta 1 is now available [...]. There is a long list of new
features since Python 1.6, released earlier today. We don't plan on
any new releases in the next 24 hours."
-- Jeremy Hylton at Slashdot
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), (continued)
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Raimar Falke, 2001/12/13
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Gregory Berkolaiko, 2001/12/13
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Raimar Falke, 2001/12/13
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Gregory Berkolaiko, 2001/12/13
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Raimar Falke, 2001/12/13
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Gregory Berkolaiko, 2001/12/13
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Raimar Falke, 2001/12/13
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Ross W. Wetmore, 2001/12/14
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Raimar Falke, 2001/12/15
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Gregory Berkolaiko, 2001/12/15
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108),
Raimar Falke <=
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Raimar Falke, 2001/12/14
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Gregory Berkolaiko, 2001/12/14
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Raimar Falke, 2001/12/14
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Gregory Berkolaiko, 2001/12/14
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Jason Short, 2001/12/13
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Gregory Berkolaiko, 2001/12/13
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Raimar Falke, 2001/12/13
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Gregory Berkolaiko, 2001/12/14
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Raimar Falke, 2001/12/14
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), Gregory Berkolaiko, 2001/12/15
|
|