Re: (PR#9610) AI movemap
"Benedict Adamson" <[email protected]> Sun, 19 Dec 2004 07:46:49 -0800
| Newsgroups | gmane.games.freeciv.ai |
|---|---|
| Message-ID | <[email protected]> |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=9610 > The movemap structure seems to mishandle deleted units. When I run valgrind on a modified version of Freeciv that uses the movemap patch, it reports accesses to deleted 'struct unit's in the movemap_iterate_one_turn and movemap_iterate_two_turn macros. I'm not sufficiently familiar with the movemap or speclist code to fully understand what is going on, but here are my observations. At first glance, the iterator macros take care to handle deleted units. The list holds unit IDs, and the macro uses find_unit_by_id to check whether the IDs corresponding to existing units. But I think something else is actually happening. The list actually holds pointers to the unit IDs (&punit->id), which is no safer than holding the pointers to the units themselves (punit). Comments?