[Freeciv-Dev] [patch #2218] [autosettler] use a hash for plr-ai-settler_map
Update of patch #2218 (project freeciv): Status: Ready For Test = Done Open/Closed:Open = Closed ___ Reply to this item at: http://gna.org/patch/?2218 ___ Nachricht geschickt von/durch Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #2218] [autosettler] use a hash for plr-ai-settler_map
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 20101121: * do not define SPECHASH_DATA_COPY as it would be a memory leak (file #11309) ___ Additional Item Attachment: File name: 20101121-08-trunk-autosettler-use-a-hash-for-plr-ai-settler_map.patch Size:26 KB ___ Reply to this item at: http://gna.org/patch/?2218 ___ Nachricht geschickt von/durch Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #2218] [autosettler] use a hash for plr-ai-settler_map
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 case, SPECHASH_DATA|KEY_COPY is useful (e.g. for strings). ___ Reply to this item at: http://gna.org/patch/?2218 ___ Message posté via/par Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #2218] [autosettler] use a hash for plr-ai-settler_map
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: http://gna.org/patch/?2218 ___ Message posté via/par Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #2218] [autosettler] use a hash for plr-ai-settler_map
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: http://gna.org/patch/?2218 ___ Message posté via/par Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #2218] [autosettler] use a hash for plr-ai-settler_map
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 * print cache results (file #11298) ___ Additional Item Attachment: File name: 20101120-08-trunk-autosettler-use-a-hash-for-plr-ai-settler_map.patch Size:26 KB ___ Reply to this item at: http://gna.org/patch/?2218 ___ Nachricht geschickt von/durch Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #2218] [autosettler] use a hash for plr-ai-settler_map
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 solutions: * You still define _SPECHASH_DATA_COPY_ and pass a built-in structure to _tile_data_cache_hash_replace()_ which will be duplicated internally. * 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()_. ___ Reply to this item at: http://gna.org/patch/?2218 ___ Message posté via/par Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #2218] [autosettler] use a hash for plr-ai-settler_map
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 Status: Ready For Test Privacy: Public Assigned to: syntron Originator Email: Open/Closed: Open Discussion Lock: Any Planned Release: 2.4.0 ___ Details: ___ File Attachments: --- Date: Freitag 19.11.2010 um 15:52 Name: 20101119-07-trunk-autosettler-use-a-hash-for-plr-ai-settler_map.patch Size: 10kB By: syntron http://gna.org/patch/download.php?file_id=11283 ___ Reply to this item at: http://gna.org/patch/?2218 ___ Nachricht geschickt von/durch Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev