Update of patch #2218 (project freeciv):
Status: Ready For Test = Done
Open/Closed:Open = Closed
___
Reply to this item at:
Follow-up Comment #5, patch #2218 (project freeciv):
Thanks for the review!
I selected the secound approach:
Then, you remove the definition of SPECHASH_DATA_COPY. Then, the
pointer you passed to tile_data_cache_hash_replace() will be
returned with tile_data_cache_hash_lookup().
changes
Follow-up Comment #6, patch #2218 (project freeciv):
And this is correct since you don't use spechash_hash_insert().
spechash_hash_replace() always set the data and the key in the hash table. As
spechash_hash_insert() doesn't, on failure, we used to forget to free the key
and the data. In this
Follow-up Comment #1, patch #2218 (project freeciv):
Note the _struct tile_data_cache_ pointers are never free-d. You should
define _SPECHASH_DATA_FREE_ to _tile_data_cache_destroy()_.
___
Reply to this item at:
Follow-up Comment #2, patch #2218 (project freeciv):
Reading again you should also defined _SPECHASH_DATA_COPY_ to
_tile_data_cache_copy()_ to auto duplicate the element when needed.
___
Reply to this item at:
Follow-up Comment #3, patch #2218 (project freeciv):
I did rewrote the entire patch. Now also the tile data in the city result is
saved using a hash. tile_data_hash_copy() and tile_data_hash_destroy() are
defined and used.
changes 20101120:
* use spechash.h for settler map and cityresult
*
Follow-up Comment #4, patch #2218 (project freeciv):
There are still losses of memory. When calling
_tile_data_cache_hash_replace(key, data)_, then data will be duplicated
inside (because _SPECHASH_DATA_COPY_ has been defined). So you need to free
the pointer after that.
So, there are 2
URL:
http://gna.org/patch/?2218
Summary: [autosettler] use a hash for plr-ai-settler_map
Project: Freeciv
Submitted by: syntron
Submitted on: Freitag 19.11.2010 um 15:52
Category: ai
Priority: 3 - Low