[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]
--- 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.
G.
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
- [Freeciv-Dev] Re: Changing interface for generate_warmap (PR#1108), (continued)
- [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), 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 <=
- [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), 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
|
|