Freeciv-3.3: /fast/freeciv/nightly/main/utility/genhash.c File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Data Structures | Macros | Functions
genhash.c File Reference
`#include <string.h>`
`#include "log.h"`
`#include "mem.h"`
`#include "shared.h"`
`#include "support.h"`
`#include "genhash.h"`

Go to the source code of this file.

## Data Structures

struct | genhash_entry
struct | genhash
struct | genhash_iter

## Macros

#define | FULL_RATIO 0.75 /* consider expanding when above this */
#define | MIN_RATIO 0.24 /* shrink when below this */
#define | GENHASH_ITER(p) ((struct genhash_iter *) (p))
#define | MIN_BUCKETS 29 /* Historical purposes. */
#define | genhash_maybe_expand(htab) genhash_maybe_resize((htab), TRUE)
#define | genhash_maybe_shrink(htab) genhash_maybe_resize((htab), FALSE)

## Functions

genhash_val_t | genhash_str_val_func (const char *vkey)
bool | genhash_str_comp_func (const char *vkey1, const char *vkey2)
char * | genhash_str_copy_func (const char *vkey)
void | genhash_str_free_func (char *vkey)
static size_t | genhash_calc_num_buckets (size_t num_entries)
static struct genhash * | genhash_new_nbuckets (genhash_val_fn_t key_val_func, genhash_comp_fn_t key_comp_func, genhash_copy_fn_t key_copy_func, genhash_free_fn_t key_free_func, genhash_copy_fn_t data_copy_func, genhash_free_fn_t data_free_func, size_t num_buckets)
struct genhash * | genhash_new_nentries_full (genhash_val_fn_t key_val_func, genhash_comp_fn_t key_comp_func, genhash_copy_fn_t key_copy_func, genhash_free_fn_t key_free_func, genhash_copy_fn_t data_copy_func, genhash_free_fn_t data_free_func, size_t nentries)
struct genhash * | genhash_new_nentries (genhash_val_fn_t key_val_func, genhash_comp_fn_t key_comp_func, size_t nentries)
struct genhash * | genhash_new_full (genhash_val_fn_t key_val_func, genhash_comp_fn_t key_comp_func, genhash_copy_fn_t key_copy_func, genhash_free_fn_t key_free_func, genhash_copy_fn_t data_copy_func, genhash_free_fn_t data_free_func)
struct genhash * | genhash_new (genhash_val_fn_t key_val_func, genhash_comp_fn_t key_comp_func)
void | genhash_destroy (struct genhash *pgenhash)
static void | genhash_resize_table (struct genhash *pgenhash, size_t new_nbuckets)
static bool | genhash_maybe_resize (struct genhash *pgenhash, bool expandingp)
static genhash_val_t | genhash_val_calc (const struct genhash *pgenhash, const void *key)
static struct genhash_entry ** | genhash_slot_lookup (const struct genhash *pgenhash, const void *key, genhash_val_t hash_val)
static void | genhash_default_get (void **pkey, void **data)
static void | genhash_slot_get (struct genhash_entry *const *slot, void **pkey, void **data)
static void | genhash_slot_create (struct genhash *pgenhash, struct genhash_entry **slot, const void *key, const void *data, genhash_val_t hash_val)
static void | genhash_slot_free (struct genhash *pgenhash, struct genhash_entry **slot)
static void | genhash_slot_set (struct genhash *pgenhash, struct genhash_entry **slot, const void *key, const void *data)
bool | genhash_set_no_shrink (struct genhash *pgenhash, bool no_shrink)
size_t | genhash_size (const struct genhash *pgenhash)
size_t | genhash_capacity (const struct genhash *pgenhash)
struct genhash * | genhash_copy (const struct genhash *pgenhash)
void | genhash_clear (struct genhash *pgenhash)
bool | genhash_insert (struct genhash *pgenhash, const void *key, const void *data)
bool | genhash_replace (struct genhash *pgenhash, const void *key, const void *data)
bool | genhash_replace_full (struct genhash *pgenhash, const void *key, const void *data, void **old_pkey, void **old_pdata)
bool | genhash_lookup (const struct genhash *pgenhash, const void *key, void **pdata)
bool | genhash_remove (struct genhash *pgenhash, const void *key)
bool | genhash_remove_full (struct genhash *pgenhash, const void *key, void **deleted_pkey, void **deleted_pdata)
bool | genhashes_are_equal (const struct genhash *pgenhash1, const struct genhash *pgenhash2)
bool | genhashes_are_equal_full (const struct genhash *pgenhash1, const struct genhash *pgenhash2, genhash_comp_fn_t data_comp_func)
size_t | genhash_iter_sizeof (void)
void * | genhash_iter_key (const struct iterator *genhash_iter)
void * | genhash_iter_value (const struct iterator *genhash_iter)
static void | genhash_iter_next (struct iterator *genhash_iter)
static void * | genhash_iter_get (const struct iterator *genhash_iter)
static bool | genhash_iter_valid (const struct iterator *genhash_iter)
static struct iterator * | genhash_iter_init_common (struct genhash_iter *iter, const struct genhash *pgenhash, void *(*get)(const struct iterator *))
struct iterator * | genhash_iter_init (struct genhash_iter *iter, const struct genhash *pgenhash)
struct iterator * | genhash_key_iter_init (struct genhash_iter *iter, const struct genhash *pgenhash)
struct iterator * | genhash_value_iter_init (struct genhash_iter *iter, const struct genhash *pgenhash)

## Macro Definition Documentation

## ◆ FULL_RATIO

#define FULL_RATIO 0.75 /* consider expanding when above this */

Definition at line 72 of file genhash.c.

## ◆ GENHASH_ITER

#define GENHASH_ITER | ( |  | p | ) | ((struct genhash_iter *) (p))

Definition at line 102 of file genhash.c.

## ◆ genhash_maybe_expand

#define genhash_maybe_expand | ( |  | htab | ) | genhash_maybe_resize((htab), TRUE)

Call this when an entry might be added or deleted: resizes the genhash table if seems like a good idea. Count deleted entries in check because efficiency may be degraded if there are too many deleted entries. But for determining new size, ignore deleted entries, since they'll be removed by rehashing.

Definition at line 338 of file genhash.c.

## ◆ genhash_maybe_shrink

#define genhash_maybe_shrink | ( |  | htab | ) | genhash_maybe_resize((htab), FALSE)

Definition at line 339 of file genhash.c.

## ◆ MIN_BUCKETS

#define MIN_BUCKETS 29 /* Historical purposes. */

Calculate a "reasonable" number of buckets for a given number of entries. Gives a prime number far from powers of 2, allowing at least a factor of 2 from the given number of entries for breathing room.

Generalized restrictions on the behavior of this function: MIN_BUCKETS <= genhash_calc_num_buckets(x) genhash_calc_num_buckets(x) * MIN_RATIO < x whenever x > MIN_BUCKETS * MIN_RATIO. genhash_calc_num_buckets(x) * FULL_RATIO > x. This one is more of a recommendation, to ensure enough free space: genhash_calc_num_buckets(x) >= 2 * x.

Definition at line 161 of file genhash.c.

## ◆ MIN_RATIO

#define MIN_RATIO 0.24 /* shrink when below this */

Definition at line 73 of file genhash.c.

## Function Documentation

## ◆ genhash_calc_num_buckets()

static size_t genhash_calc_num_buckets | ( | size_t | num_entries | ) |

static

Definition at line 162 of file genhash.c.

Referenced by genhash_maybe_resize(), genhash_new_nentries(), and genhash_new_nentries_full().

## ◆ genhash_capacity()

size_t genhash_capacity | ( | const struct genhash * | pgenhash | ) |

Returns the number of buckets in the genhash table.

Definition at line 534 of file genhash.c.

Referenced by _hash_capacity().

## ◆ genhash_clear()

void genhash_clear | ( | struct genhash * | pgenhash | ) |

Remove all entries of the genhash table.

Definition at line 582 of file genhash.c.

Referenced by _hash_clear(), conn_reset_delta_state(), and genhash_destroy().

## ◆ genhash_copy()

struct genhash * genhash_copy | ( | const struct genhash * | pgenhash | ) |

Returns a newly allocated mostly deep copy of the given genhash table.

Definition at line 543 of file genhash.c.

Referenced by _hash_copy().

## ◆ genhash_default_get()

static void genhash_default_get | ( | void ** | pkey,
|  | void ** | data
| ) |  |

inlinestatic

Function to store from invalid data.

Definition at line 424 of file genhash.c.

Referenced by genhash_lookup(), genhash_remove_full(), and genhash_replace_full().

## ◆ genhash_destroy()

void genhash_destroy | ( | struct genhash * | pgenhash | ) |

Destructor: free internal memory.

Definition at line 293 of file genhash.c.

Referenced by _hash_destroy(), and free_packet_hashes().

## ◆ genhash_insert()

bool genhash_insert | ( | struct genhash * | pgenhash,
|  | const void * | key,
|  | const void * | data
| ) |  |

Insert entry: returns TRUE if inserted, or FALSE if there was already an entry with the same key, in which case the entry was not inserted.

Definition at line 604 of file genhash.c.

Referenced by _hash_insert(), receive_packet_achievement_info_100(), receive_packet_authentication_reply_100(), receive_packet_authentication_req_100(), receive_packet_calendar_info_100(), receive_packet_chat_msg_100(), receive_packet_chat_msg_req_100(), receive_packet_city_buy_100(), receive_packet_city_change_100(), receive_packet_city_change_specialist_100(), receive_packet_city_info_100(), receive_packet_city_make_specialist_100(), receive_packet_city_make_worker_100(), receive_packet_city_name_suggestion_info_100(), receive_packet_city_name_suggestion_req_100(), receive_packet_city_nationalities_100(), receive_packet_city_options_req_100(), receive_packet_city_rally_point_100(), receive_packet_city_refresh_100(), receive_packet_city_remove_100(), receive_packet_city_rename_100(), receive_packet_city_sabotage_list_100(), receive_packet_city_sell_100(), receive_packet_city_short_info_100(), receive_packet_city_update_counters_100(), receive_packet_city_worklist_100(), receive_packet_client_info_100(), receive_packet_conn_info_100(), receive_packet_conn_ping_info_100(), receive_packet_connect_msg_100(), receive_packet_diplomacy_accept_treaty_100(), receive_packet_diplomacy_accept_treaty_req_100(), receive_packet_diplomacy_cancel_meeting_100(), receive_packet_diplomacy_cancel_meeting_req_100(), receive_packet_diplomacy_cancel_pact_100(), receive_packet_diplomacy_create_clause_100(), receive_packet_diplomacy_create_clause_req_100(), receive_packet_diplomacy_init_meeting_100(), receive_packet_diplomacy_init_meeting_req_100(), receive_packet_diplomacy_remove_clause_100(), receive_packet_diplomacy_remove_clause_req_100(), receive_packet_early_chat_msg_100(), receive_packet_edit_city_100(), receive_packet_edit_city_create_100(), receive_packet_edit_city_remove_100(), receive_packet_edit_game_100(), receive_packet_edit_mode_100(), receive_packet_edit_object_created_100(), receive_packet_edit_player_100(), receive_packet_edit_player_create_100(), receive_packet_edit_player_remove_100(), receive_packet_edit_player_vision_100(), receive_packet_edit_scenario_desc_100(), receive_packet_edit_tile_100(), receive_packet_edit_tile_extra_100(), receive_packet_edit_tile_terrain_100(), receive_packet_edit_toggle_fogofwar_100(), receive_packet_edit_unit_100(), receive_packet_edit_unit_create_100(), receive_packet_edit_unit_remove_100(), receive_packet_edit_unit_remove_by_id_100(), receive_packet_game_info_100(), receive_packet_game_load_100(), receive_packet_investigate_finished_100(), receive_packet_investigate_started_100(), receive_packet_map_info_100(), receive_packet_nation_availability_100(), receive_packet_nation_select_req_100(), receive_packet_new_year_100(), receive_packet_nuke_tile_info_100(), receive_packet_page_msg_100(), receive_packet_page_msg_part_100(), receive_packet_play_music_100(), receive_packet_player_attribute_chunk_100(), receive_packet_player_change_government_100(), receive_packet_player_diplstate_100(), receive_packet_player_info_100(), receive_packet_player_multiplier_100(), receive_packet_player_phase_done_100(), receive_packet_player_place_infra_100(), receive_packet_player_rates_100(), receive_packet_player_ready_100(), receive_packet_player_remove_100(), receive_packet_player_research_100(), receive_packet_player_tech_goal_100(), receive_packet_popup_image_100(), receive_packet_report_req_100(), receive_packet_research_info_100(), receive_packet_ruleset_achievement_100(), receive_packet_ruleset_action_100(), receive_packet_ruleset_action_auto_100(), receive_packet_ruleset_action_enabler_100(), receive_packet_ruleset_base_100(), receive_packet_ruleset_building_100(), receive_packet_ruleset_choices_100(), receive_packet_ruleset_city_100(), receive_packet_ruleset_clause_100(), receive_packet_ruleset_control_100(), receive_packet_ruleset_counter_100(), receive_packet_ruleset_description_part_100(), receive_packet_ruleset_disaster_100(), receive_packet_ruleset_effect_100(), receive_packet_ruleset_extra_100(), receive_packet_ruleset_extra_flag_100(), receive_packet_ruleset_game_100(), receive_packet_ruleset_goods_100(), receive_packet_ruleset_government_100(), receive_packet_ruleset_government_ruler_title_100(), receive_packet_ruleset_impr_flag_100(), receive_packet_ruleset_multiplier_100(), receive_packet_ruleset_music_100(), receive_packet_ruleset_nation_100(), receive_packet_ruleset_nation_groups_100(), receive_packet_ruleset_nation_sets_100(), receive_packet_ruleset_resource_100(), receive_packet_ruleset_road_100(), receive_packet_ruleset_select_100(), receive_packet_ruleset_specialist_100(), receive_packet_ruleset_style_100(), receive_packet_ruleset_summary_100(), receive_packet_ruleset_tech_100(), receive_packet_ruleset_tech_class_100(), receive_packet_ruleset_tech_flag_100(), receive_packet_ruleset_terrain_100(), receive_packet_ruleset_terrain_control_100(), receive_packet_ruleset_terrain_flag_100(), receive_packet_ruleset_trade_100(), receive_packet_ruleset_unit_100(), receive_packet_ruleset_unit_bonus_100(), receive_packet_ruleset_unit_class_100(), receive_packet_ruleset_unit_class_flag_100(), receive_packet_ruleset_unit_flag_100(), receive_packet_save_scenario_100(), receive_packet_scenario_description_100(), receive_packet_scenario_info_100(), receive_packet_server_info_100(), receive_packet_server_setting_bitwise_100(), receive_packet_server_setting_bool_100(), receive_packet_server_setting_const_100(), receive_packet_server_setting_control_100(), receive_packet_server_setting_enum_100(), receive_packet_server_setting_int_100(), receive_packet_server_setting_str_100(), receive_packet_set_topology_100(), receive_packet_single_want_hack_reply_100(), receive_packet_single_want_hack_req_100(), receive_packet_spaceship_info_100(), receive_packet_spaceship_place_100(), receive_packet_start_phase_100(), receive_packet_team_name_info_100(), receive_packet_tile_info_100(), receive_packet_timeout_info_100(), receive_packet_trade_route_info_100(), receive_packet_unit_action_answer_100(), receive_packet_unit_action_query_100(), receive_packet_unit_actions_100(), receive_packet_unit_change_activity_100(), receive_packet_unit_combat_info_100(), receive_packet_unit_do_action_100(), receive_packet_unit_get_actions_100(), receive_packet_unit_info_100(), receive_packet_unit_orders_100(), receive_packet_unit_remove_100(), receive_packet_unit_server_side_agent_set_100(), receive_packet_unit_short_info_100(), receive_packet_unit_sscs_set_100(), receive_packet_unit_type_upgrade_100(), receive_packet_unknown_research_100(), receive_packet_vote_new_100(), receive_packet_vote_remove_100(), receive_packet_vote_resolve_100(), receive_packet_vote_update_100(), receive_packet_web_city_info_addition_100(), receive_packet_web_cma_clear_100(), receive_packet_web_cma_set_100(), receive_packet_web_player_info_addition_100(), receive_packet_web_ruleset_unit_addition_100(), receive_packet_worker_task_100(), send_packet_achievement_info_100(), send_packet_authentication_reply_100(), send_packet_authentication_req_100(), send_packet_calendar_info_100(), send_packet_chat_msg_100(), send_packet_chat_msg_req_100(), send_packet_city_buy_100(), send_packet_city_change_100(), send_packet_city_change_specialist_100(), send_packet_city_info_100(), send_packet_city_make_specialist_100(), send_packet_city_make_worker_100(), send_packet_city_name_suggestion_info_100(), send_packet_city_name_suggestion_req_100(), send_packet_city_nationalities_100(), send_packet_city_options_req_100(), send_packet_city_rally_point_100(), send_packet_city_refresh_100(), send_packet_city_remove_100(), send_packet_city_rename_100(), send_packet_city_sabotage_list_100(), send_packet_city_sell_100(), send_packet_city_short_info_100(), send_packet_city_update_counters_100(), send_packet_city_worklist_100(), send_packet_client_info_100(), send_packet_conn_info_100(), send_packet_conn_ping_info_100(), send_packet_connect_msg_100(), send_packet_diplomacy_accept_treaty_100(), send_packet_diplomacy_accept_treaty_req_100(), send_packet_diplomacy_cancel_meeting_100(), send_packet_diplomacy_cancel_meeting_req_100(), send_packet_diplomacy_cancel_pact_100(), send_packet_diplomacy_create_clause_100(), send_packet_diplomacy_create_clause_req_100(), send_packet_diplomacy_init_meeting_100(), send_packet_diplomacy_init_meeting_req_100(), send_packet_diplomacy_remove_clause_100(), send_packet_diplomacy_remove_clause_req_100(), send_packet_early_chat_msg_100(), send_packet_edit_city_100(), send_packet_edit_city_create_100(), send_packet_edit_city_remove_100(), send_packet_edit_game_100(), send_packet_edit_mode_100(), send_packet_edit_object_created_100(), send_packet_edit_player_100(), send_packet_edit_player_create_100(), send_packet_edit_player_remove_100(), send_packet_edit_player_vision_100(), send_packet_edit_scenario_desc_100(), send_packet_edit_tile_100(), send_packet_edit_tile_extra_100(), send_packet_edit_tile_terrain_100(), send_packet_edit_toggle_fogofwar_100(), send_packet_edit_unit_100(), send_packet_edit_unit_create_100(), send_packet_edit_unit_remove_100(), send_packet_edit_unit_remove_by_id_100(), send_packet_game_info_100(), send_packet_game_load_100(), send_packet_investigate_finished_100(), send_packet_investigate_started_100(), send_packet_map_info_100(), send_packet_nation_availability_100(), send_packet_nation_select_req_100(), send_packet_new_year_100(), send_packet_nuke_tile_info_100(), send_packet_page_msg_100(), send_packet_page_msg_part_100(), send_packet_play_music_100(), send_packet_player_attribute_chunk_100(), send_packet_player_change_government_100(), send_packet_player_diplstate_100(), send_packet_player_info_100(), send_packet_player_multiplier_100(), send_packet_player_phase_done_100(), send_packet_player_place_infra_100(), send_packet_player_rates_100(), send_packet_player_ready_100(), send_packet_player_remove_100(), send_packet_player_research_100(), send_packet_player_tech_goal_100(), send_packet_popup_image_100(), send_packet_report_req_100(), send_packet_research_info_100(), send_packet_ruleset_achievement_100(), send_packet_ruleset_action_100(), send_packet_ruleset_action_auto_100(), send_packet_ruleset_action_enabler_100(), send_packet_ruleset_base_100(), send_packet_ruleset_building_100(), send_packet_ruleset_choices_100(), send_packet_ruleset_city_100(), send_packet_ruleset_clause_100(), send_packet_ruleset_control_100(), send_packet_ruleset_counter_100(), send_packet_ruleset_description_part_100(), send_packet_ruleset_disaster_100(), send_packet_ruleset_effect_100(), send_packet_ruleset_extra_100(), send_packet_ruleset_extra_flag_100(), send_packet_ruleset_game_100(), send_packet_ruleset_goods_100(), send_packet_ruleset_government_100(), send_packet_ruleset_government_ruler_title_100(), send_packet_ruleset_impr_flag_100(), send_packet_ruleset_multiplier_100(), send_packet_ruleset_music_100(), send_packet_ruleset_nation_100(), send_packet_ruleset_nation_groups_100(), send_packet_ruleset_nation_sets_100(), send_packet_ruleset_resource_100(), send_packet_ruleset_road_100(), send_packet_ruleset_select_100(), send_packet_ruleset_specialist_100(), send_packet_ruleset_style_100(), send_packet_ruleset_summary_100(), send_packet_ruleset_tech_100(), send_packet_ruleset_tech_class_100(), send_packet_ruleset_tech_flag_100(), send_packet_ruleset_terrain_100(), send_packet_ruleset_terrain_control_100(), send_packet_ruleset_terrain_flag_100(), send_packet_ruleset_trade_100(), send_packet_ruleset_unit_100(), send_packet_ruleset_unit_bonus_100(), send_packet_ruleset_unit_class_100(), send_packet_ruleset_unit_class_flag_100(), send_packet_ruleset_unit_flag_100(), send_packet_save_scenario_100(), send_packet_scenario_description_100(), send_packet_scenario_info_100(), send_packet_server_info_100(), send_packet_server_setting_bitwise_100(), send_packet_server_setting_bool_100(), send_packet_server_setting_const_100(), send_packet_server_setting_control_100(), send_packet_server_setting_enum_100(), send_packet_server_setting_int_100(), send_packet_server_setting_str_100(), send_packet_set_topology_100(), send_packet_single_want_hack_reply_100(), send_packet_single_want_hack_req_100(), send_packet_spaceship_info_100(), send_packet_spaceship_place_100(), send_packet_start_phase_100(), send_packet_team_name_info_100(), send_packet_tile_info_100(), send_packet_timeout_info_100(), send_packet_trade_route_info_100(), send_packet_unit_action_answer_100(), send_packet_unit_action_query_100(), send_packet_unit_actions_100(), send_packet_unit_change_activity_100(), send_packet_unit_combat_info_100(), send_packet_unit_do_action_100(), send_packet_unit_get_actions_100(), send_packet_unit_info_100(), send_packet_unit_orders_100(), send_packet_unit_remove_100(), send_packet_unit_server_side_agent_set_100(), send_packet_unit_short_info_100(), send_packet_unit_sscs_set_100(), send_packet_unit_type_upgrade_100(), send_packet_unknown_research_100(), send_packet_vote_new_100(), send_packet_vote_remove_100(), send_packet_vote_resolve_100(), send_packet_vote_update_100(), send_packet_web_city_info_addition_100(), send_packet_web_cma_clear_100(), send_packet_web_cma_set_100(), send_packet_web_player_info_addition_100(), send_packet_web_ruleset_unit_addition_100(), and send_packet_worker_task_100().

## ◆ genhash_iter_get()

static void * genhash_iter_get | ( | const struct iterator * | genhash_iter | ) |

static

Iterator interface 'get' function implementation. This just returns the iterator itself, so you would need to use genhash_iter_get_key/value to get the actual keys and values.

Definition at line 843 of file genhash.c.

Referenced by genhash_iter_init().

## ◆ genhash_iter_init()

struct iterator * genhash_iter_init | ( | struct genhash_iter * | iter,
|  | const struct genhash * | pgenhash
| ) |  |

Returns an iterator that iterates over both keys and values of the genhash table. NB: iterator_get() returns an iterator pointer, so use the helper functions genhash_iter_get_{key,value} to access the key and value.

Definition at line 891 of file genhash.c.

Referenced by _hash_iter_init().

## ◆ genhash_iter_init_common()

static struct iterator * genhash_iter_init_common | ( | struct genhash_iter * | iter,
|  | const struct genhash * | pgenhash,
|  | void *(*)(const struct iterator *) | get
| ) |  |

inlinestatic

Common genhash iterator initializer.

Definition at line 861 of file genhash.c.

Referenced by genhash_iter_init(), genhash_key_iter_init(), and genhash_value_iter_init().

## ◆ genhash_iter_key()

void * genhash_iter_key | ( | const struct iterator * | genhash_iter | ) |

Helper function for genhash (key, value) pair iteration.

Definition at line 803 of file genhash.c.

Referenced by genhash_key_iter_init().

## ◆ genhash_iter_next()

static void genhash_iter_next | ( | struct iterator * | genhash_iter | ) |

static

Iterator interface 'next' function implementation.

Definition at line 821 of file genhash.c.

Referenced by genhash_iter_init_common().

## ◆ genhash_iter_sizeof()

size_t genhash_iter_sizeof | ( | void |  | ) |

"Sizeof" function implementation for generic_iterate genhash iterators.

Definition at line 795 of file genhash.c.

Referenced by _hash_iter_sizeof().

## ◆ genhash_iter_valid()

static bool genhash_iter_valid | ( | const struct iterator * | genhash_iter | ) |

static

Iterator interface 'valid' function implementation.

Definition at line 851 of file genhash.c.

Referenced by genhash_iter_init_common().

## ◆ genhash_iter_value()

void * genhash_iter_value | ( | const struct iterator * | genhash_iter | ) |

Helper function for genhash (key, value) pair iteration.

Definition at line 812 of file genhash.c.

Referenced by genhash_value_iter_init().

## ◆ genhash_key_iter_init()

struct iterator * genhash_key_iter_init | ( | struct genhash_iter * | iter,
|  | const struct genhash * | pgenhash
| ) |  |

Returns an iterator over the genhash table's k genhashgenhashenhashys.

Definition at line 900 of file genhash.c.

Referenced by _hash_key_iter_init().

## ◆ genhash_lookup()

bool genhash_lookup | ( | const struct genhash * | pgenhash,
|  | const void * | key,
|  | void ** | pdata
| ) |  |

Lookup data. Return TRUE on success, then pdata - if not NULL will be set to the data value.

Definition at line 681 of file genhash.c.

Referenced by _hash_lookup(), receive_packet_achievement_info_100(), receive_packet_authentication_reply_100(), receive_packet_authentication_req_100(), receive_packet_calendar_info_100(), receive_packet_chat_msg_100(), receive_packet_chat_msg_req_100(), receive_packet_city_buy_100(), receive_packet_city_change_100(), receive_packet_city_change_specialist_100(), receive_packet_city_info_100(), receive_packet_city_make_specialist_100(), receive_packet_city_make_worker_100(), receive_packet_city_name_suggestion_info_100(), receive_packet_city_name_suggestion_req_100(), receive_packet_city_nationalities_100(), receive_packet_city_options_req_100(), receive_packet_city_rally_point_100(), receive_packet_city_refresh_100(), receive_packet_city_remove_100(), receive_packet_city_rename_100(), receive_packet_city_sabotage_list_100(), receive_packet_city_sell_100(), receive_packet_city_short_info_100(), receive_packet_city_update_counters_100(), receive_packet_city_worklist_100(), receive_packet_client_info_100(), receive_packet_conn_info_100(), receive_packet_conn_ping_info_100(), receive_packet_connect_msg_100(), receive_packet_diplomacy_accept_treaty_100(), receive_packet_diplomacy_accept_treaty_req_100(), receive_packet_diplomacy_cancel_meeting_100(), receive_packet_diplomacy_cancel_meeting_req_100(), receive_packet_diplomacy_cancel_pact_100(), receive_packet_diplomacy_create_clause_100(), receive_packet_diplomacy_create_clause_req_100(), receive_packet_diplomacy_init_meeting_100(), receive_packet_diplomacy_init_meeting_req_100(), receive_packet_diplomacy_remove_clause_100(), receive_packet_diplomacy_remove_clause_req_100(), receive_packet_early_chat_msg_100(), receive_packet_edit_city_100(), receive_packet_edit_city_create_100(), receive_packet_edit_city_remove_100(), receive_packet_edit_game_100(), receive_packet_edit_mode_100(), receive_packet_edit_object_created_100(), receive_packet_edit_player_100(), receive_packet_edit_player_create_100(), receive_packet_edit_player_remove_100(), receive_packet_edit_player_vision_100(), receive_packet_edit_scenario_desc_100(), receive_packet_edit_tile_100(), receive_packet_edit_tile_extra_100(), receive_packet_edit_tile_terrain_100(), receive_packet_edit_toggle_fogofwar_100(), receive_packet_edit_unit_100(), receive_packet_edit_unit_create_100(), receive_packet_edit_unit_remove_100(), receive_packet_edit_unit_remove_by_id_100(), receive_packet_game_info_100(), receive_packet_game_load_100(), receive_packet_investigate_finished_100(), receive_packet_investigate_started_100(), receive_packet_map_info_100(), receive_packet_nation_availability_100(), receive_packet_nation_select_req_100(), receive_packet_new_year_100(), receive_packet_nuke_tile_info_100(), receive_packet_page_msg_100(), receive_packet_page_msg_part_100(), receive_packet_play_music_100(), receive_packet_player_attribute_chunk_100(), receive_packet_player_change_government_100(), receive_packet_player_diplstate_100(), receive_packet_player_info_100(), receive_packet_player_multiplier_100(), receive_packet_player_phase_done_100(), receive_packet_player_place_infra_100(), receive_packet_player_rates_100(), receive_packet_player_ready_100(), receive_packet_player_remove_100(), receive_packet_player_research_100(), receive_packet_player_tech_goal_100(), receive_packet_popup_image_100(), receive_packet_report_req_100(), receive_packet_research_info_100(), receive_packet_ruleset_achievement_100(), receive_packet_ruleset_action_100(), receive_packet_ruleset_action_auto_100(), receive_packet_ruleset_action_enabler_100(), receive_packet_ruleset_base_100(), receive_packet_ruleset_building_100(), receive_packet_ruleset_choices_100(), receive_packet_ruleset_city_100(), receive_packet_ruleset_clause_100(), receive_packet_ruleset_control_100(), receive_packet_ruleset_counter_100(), receive_packet_ruleset_description_part_100(), receive_packet_ruleset_disaster_100(), receive_packet_ruleset_effect_100(), receive_packet_ruleset_extra_100(), receive_packet_ruleset_extra_flag_100(), receive_packet_ruleset_game_100(), receive_packet_ruleset_goods_100(), receive_packet_ruleset_government_100(), receive_packet_ruleset_government_ruler_title_100(), receive_packet_ruleset_impr_flag_100(), receive_packet_ruleset_multiplier_100(), receive_packet_ruleset_music_100(), receive_packet_ruleset_nation_100(), receive_packet_ruleset_nation_groups_100(), receive_packet_ruleset_nation_sets_100(), receive_packet_ruleset_resource_100(), receive_packet_ruleset_road_100(), receive_packet_ruleset_select_100(), receive_packet_ruleset_specialist_100(), receive_packet_ruleset_style_100(), receive_packet_ruleset_summary_100(), receive_packet_ruleset_tech_100(), receive_packet_ruleset_tech_class_100(), receive_packet_ruleset_tech_flag_100(), receive_packet_ruleset_terrain_100(), receive_packet_ruleset_terrain_control_100(), receive_packet_ruleset_terrain_flag_100(), receive_packet_ruleset_trade_100(), receive_packet_ruleset_unit_100(), receive_packet_ruleset_unit_bonus_100(), receive_packet_ruleset_unit_class_100(), receive_packet_ruleset_unit_class_flag_100(), receive_packet_ruleset_unit_flag_100(), receive_packet_save_scenario_100(), receive_packet_scenario_description_100(), receive_packet_scenario_info_100(), receive_packet_server_info_100(), receive_packet_server_setting_bitwise_100(), receive_packet_server_setting_bool_100(), receive_packet_server_setting_const_100(), receive_packet_server_setting_control_100(), receive_packet_server_setting_enum_100(), receive_packet_server_setting_int_100(), receive_packet_server_setting_str_100(), receive_packet_set_topology_100(), receive_packet_single_want_hack_reply_100(), receive_packet_single_want_hack_req_100(), receive_packet_spaceship_info_100(), receive_packet_spaceship_place_100(), receive_packet_start_phase_100(), receive_packet_team_name_info_100(), receive_packet_tile_info_100(), receive_packet_timeout_info_100(), receive_packet_trade_route_info_100(), receive_packet_unit_action_answer_100(), receive_packet_unit_action_query_100(), receive_packet_unit_actions_100(), receive_packet_unit_change_activity_100(), receive_packet_unit_combat_info_100(), receive_packet_unit_do_action_100(), receive_packet_unit_get_actions_100(), receive_packet_unit_info_100(), receive_packet_unit_orders_100(), receive_packet_unit_remove_100(), receive_packet_unit_server_side_agent_set_100(), receive_packet_unit_short_info_100(), receive_packet_unit_sscs_set_100(), receive_packet_unit_type_upgrade_100(), receive_packet_unknown_research_100(), receive_packet_vote_new_100(), receive_packet_vote_remove_100(), receive_packet_vote_resolve_100(), receive_packet_vote_update_100(), receive_packet_web_city_info_addition_100(), receive_packet_web_cma_clear_100(), receive_packet_web_cma_set_100(), receive_packet_web_player_info_addition_100(), receive_packet_web_ruleset_unit_addition_100(), receive_packet_worker_task_100(), send_packet_achievement_info_100(), send_packet_authentication_reply_100(), send_packet_authentication_req_100(), send_packet_calendar_info_100(), send_packet_chat_msg_100(), send_packet_chat_msg_req_100(), send_packet_city_buy_100(), send_packet_city_change_100(), send_packet_city_change_specialist_100(), send_packet_city_info_100(), send_packet_city_make_specialist_100(), send_packet_city_make_worker_100(), send_packet_city_name_suggestion_info_100(), send_packet_city_name_suggestion_req_100(), send_packet_city_nationalities_100(), send_packet_city_options_req_100(), send_packet_city_rally_point_100(), send_packet_city_refresh_100(), send_packet_city_remove_100(), send_packet_city_rename_100(), send_packet_city_sabotage_list_100(), send_packet_city_sell_100(), send_packet_city_short_info_100(), send_packet_city_update_counters_100(), send_packet_city_worklist_100(), send_packet_client_info_100(), send_packet_conn_info_100(), send_packet_conn_ping_info_100(), send_packet_connect_msg_100(), send_packet_diplomacy_accept_treaty_100(), send_packet_diplomacy_accept_treaty_req_100(), send_packet_diplomacy_cancel_meeting_100(), send_packet_diplomacy_cancel_meeting_req_100(), send_packet_diplomacy_cancel_pact_100(), send_packet_diplomacy_create_clause_100(), send_packet_diplomacy_create_clause_req_100(), send_packet_diplomacy_init_meeting_100(), send_packet_diplomacy_init_meeting_req_100(), send_packet_diplomacy_remove_clause_100(), send_packet_diplomacy_remove_clause_req_100(), send_packet_early_chat_msg_100(), send_packet_edit_city_100(), send_packet_edit_city_create_100(), send_packet_edit_city_remove_100(), send_packet_edit_game_100(), send_packet_edit_mode_100(), send_packet_edit_object_created_100(), send_packet_edit_player_100(), send_packet_edit_player_create_100(), send_packet_edit_player_remove_100(), send_packet_edit_player_vision_100(), send_packet_edit_scenario_desc_100(), send_packet_edit_tile_100(), send_packet_edit_tile_extra_100(), send_packet_edit_tile_terrain_100(), send_packet_edit_toggle_fogofwar_100(), send_packet_edit_unit_100(), send_packet_edit_unit_create_100(), send_packet_edit_unit_remove_100(), send_packet_edit_unit_remove_by_id_100(), send_packet_game_info_100(), send_packet_game_load_100(), send_packet_investigate_finished_100(), send_packet_investigate_started_100(), send_packet_map_info_100(), send_packet_nation_availability_100(), send_packet_nation_select_req_100(), send_packet_new_year_100(), send_packet_nuke_tile_info_100(), send_packet_page_msg_100(), send_packet_page_msg_part_100(), send_packet_play_music_100(), send_packet_player_attribute_chunk_100(), send_packet_player_change_government_100(), send_packet_player_diplstate_100(), send_packet_player_info_100(), send_packet_player_multiplier_100(), send_packet_player_phase_done_100(), send_packet_player_place_infra_100(), send_packet_player_rates_100(), send_packet_player_ready_100(), send_packet_player_remove_100(), send_packet_player_research_100(), send_packet_player_tech_goal_100(), send_packet_popup_image_100(), send_packet_report_req_100(), send_packet_research_info_100(), send_packet_ruleset_achievement_100(), send_packet_ruleset_action_100(), send_packet_ruleset_action_auto_100(), send_packet_ruleset_action_enabler_100(), send_packet_ruleset_base_100(), send_packet_ruleset_building_100(), send_packet_ruleset_choices_100(), send_packet_ruleset_city_100(), send_packet_ruleset_clause_100(), send_packet_ruleset_control_100(), send_packet_ruleset_counter_100(), send_packet_ruleset_description_part_100(), send_packet_ruleset_disaster_100(), send_packet_ruleset_effect_100(), send_packet_ruleset_extra_100(), send_packet_ruleset_extra_flag_100(), send_packet_ruleset_game_100(), send_packet_ruleset_goods_100(), send_packet_ruleset_government_100(), send_packet_ruleset_government_ruler_title_100(), send_packet_ruleset_impr_flag_100(), send_packet_ruleset_multiplier_100(), send_packet_ruleset_music_100(), send_packet_ruleset_nation_100(), send_packet_ruleset_nation_groups_100(), send_packet_ruleset_nation_sets_100(), send_packet_ruleset_resource_100(), send_packet_ruleset_road_100(), send_packet_ruleset_select_100(), send_packet_ruleset_specialist_100(), send_packet_ruleset_style_100(), send_packet_ruleset_summary_100(), send_packet_ruleset_tech_100(), send_packet_ruleset_tech_class_100(), send_packet_ruleset_tech_flag_100(), send_packet_ruleset_terrain_100(), send_packet_ruleset_terrain_control_100(), send_packet_ruleset_terrain_flag_100(), send_packet_ruleset_trade_100(), send_packet_ruleset_unit_100(), send_packet_ruleset_unit_bonus_100(), send_packet_ruleset_unit_class_100(), send_packet_ruleset_unit_class_flag_100(), send_packet_ruleset_unit_flag_100(), send_packet_save_scenario_100(), send_packet_scenario_description_100(), send_packet_scenario_info_100(), send_packet_server_info_100(), send_packet_server_setting_bitwise_100(), send_packet_server_setting_bool_100(), send_packet_server_setting_const_100(), send_packet_server_setting_control_100(), send_packet_server_setting_enum_100(), send_packet_server_setting_int_100(), send_packet_server_setting_str_100(), send_packet_set_topology_100(), send_packet_single_want_hack_reply_100(), send_packet_single_want_hack_req_100(), send_packet_spaceship_info_100(), send_packet_spaceship_place_100(), send_packet_start_phase_100(), send_packet_team_name_info_100(), send_packet_tile_info_100(), send_packet_timeout_info_100(), send_packet_trade_route_info_100(), send_packet_unit_action_answer_100(), send_packet_unit_action_query_100(), send_packet_unit_actions_100(), send_packet_unit_change_activity_100(), send_packet_unit_combat_info_100(), send_packet_unit_do_action_100(), send_packet_unit_get_actions_100(), send_packet_unit_info_100(), send_packet_unit_orders_100(), send_packet_unit_remove_100(), send_packet_unit_server_side_agent_set_100(), send_packet_unit_short_info_100(), send_packet_unit_sscs_set_100(), send_packet_unit_type_upgrade_100(), send_packet_unknown_research_100(), send_packet_vote_new_100(), send_packet_vote_remove_100(), send_packet_vote_resolve_100(), send_packet_vote_update_100(), send_packet_web_city_info_addition_100(), send_packet_web_cma_clear_100(), send_packet_web_cma_set_100(), send_packet_web_player_info_addition_100(), send_packet_web_ruleset_unit_addition_100(), and send_packet_worker_task_100().

## ◆ genhash_maybe_resize()

static bool genhash_maybe_resize | ( | struct genhash * | pgenhash,
|  | bool | expandingp
| ) |  |

static

Definition at line 340 of file genhash.c.

## ◆ genhash_new()

struct genhash * genhash_new | ( | genhash_val_fn_t | key_val_func,
|  | genhash_comp_fn_t | key_comp_func
| ) |  |

Constructor with unspecified number of entries.

Definition at line 283 of file genhash.c.

## ◆ genhash_new_full()

struct genhash * genhash_new_full | ( | genhash_val_fn_t | key_val_func,
|  | genhash_comp_fn_t | key_comp_func,
|  | genhash_copy_fn_t | key_copy_func,
|  | genhash_free_fn_t | key_free_func,
|  | genhash_copy_fn_t | data_copy_func,
|  | genhash_free_fn_t | data_free_func
| ) |  |

Constructor with unspecified number of entries. Allows to specify functions to free the memory allocated for the key and user-data that get called when removing the bucket from the hash table or changing key/user-data values.

Definition at line 268 of file genhash.c.

Referenced by _hash_new_full(), receive_packet_achievement_info_100(), receive_packet_authentication_reply_100(), receive_packet_authentication_req_100(), receive_packet_calendar_info_100(), receive_packet_chat_msg_100(), receive_packet_chat_msg_req_100(), receive_packet_city_buy_100(), receive_packet_city_change_100(), receive_packet_city_change_specialist_100(), receive_packet_city_info_100(), receive_packet_city_make_specialist_100(), receive_packet_city_make_worker_100(), receive_packet_city_name_suggestion_info_100(), receive_packet_city_name_suggestion_req_100(), receive_packet_city_nationalities_100(), receive_packet_city_options_req_100(), receive_packet_city_rally_point_100(), receive_packet_city_refresh_100(), receive_packet_city_remove_100(), receive_packet_city_rename_100(), receive_packet_city_sabotage_list_100(), receive_packet_city_sell_100(), receive_packet_city_short_info_100(), receive_packet_city_update_counters_100(), receive_packet_city_worklist_100(), receive_packet_client_info_100(), receive_packet_conn_info_100(), receive_packet_conn_ping_info_100(), receive_packet_connect_msg_100(), receive_packet_diplomacy_accept_treaty_100(), receive_packet_diplomacy_accept_treaty_req_100(), receive_packet_diplomacy_cancel_meeting_100(), receive_packet_diplomacy_cancel_meeting_req_100(), receive_packet_diplomacy_cancel_pact_100(), receive_packet_diplomacy_create_clause_100(), receive_packet_diplomacy_create_clause_req_100(), receive_packet_diplomacy_init_meeting_100(), receive_packet_diplomacy_init_meeting_req_100(), receive_packet_diplomacy_remove_clause_100(), receive_packet_diplomacy_remove_clause_req_100(), receive_packet_early_chat_msg_100(), receive_packet_edit_city_100(), receive_packet_edit_city_create_100(), receive_packet_edit_city_remove_100(), receive_packet_edit_game_100(), receive_packet_edit_mode_100(), receive_packet_edit_object_created_100(), receive_packet_edit_player_100(), receive_packet_edit_player_create_100(), receive_packet_edit_player_remove_100(), receive_packet_edit_player_vision_100(), receive_packet_edit_scenario_desc_100(), receive_packet_edit_tile_100(), receive_packet_edit_tile_extra_100(), receive_packet_edit_tile_terrain_100(), receive_packet_edit_toggle_fogofwar_100(), receive_packet_edit_unit_100(), receive_packet_edit_unit_create_100(), receive_packet_edit_unit_remove_100(), receive_packet_edit_unit_remove_by_id_100(), receive_packet_game_info_100(), receive_packet_game_load_100(), receive_packet_investigate_finished_100(), receive_packet_investigate_started_100(), receive_packet_map_info_100(), receive_packet_nation_availability_100(), receive_packet_nation_select_req_100(), receive_packet_new_year_100(), receive_packet_nuke_tile_info_100(), receive_packet_page_msg_100(), receive_packet_page_msg_part_100(), receive_packet_play_music_100(), receive_packet_player_attribute_chunk_100(), receive_packet_player_change_government_100(), receive_packet_player_diplstate_100(), receive_packet_player_info_100(), receive_packet_player_multiplier_100(), receive_packet_player_phase_done_100(), receive_packet_player_place_infra_100(), receive_packet_player_rates_100(), receive_packet_player_ready_100(), receive_packet_player_remove_100(), receive_packet_player_research_100(), receive_packet_player_tech_goal_100(), receive_packet_popup_image_100(), receive_packet_report_req_100(), receive_packet_research_info_100(), receive_packet_ruleset_achievement_100(), receive_packet_ruleset_action_100(), receive_packet_ruleset_action_auto_100(), receive_packet_ruleset_action_enabler_100(), receive_packet_ruleset_base_100(), receive_packet_ruleset_building_100(), receive_packet_ruleset_choices_100(), receive_packet_ruleset_city_100(), receive_packet_ruleset_clause_100(), receive_packet_ruleset_control_100(), receive_packet_ruleset_counter_100(), receive_packet_ruleset_description_part_100(), receive_packet_ruleset_disaster_100(), receive_packet_ruleset_effect_100(), receive_packet_ruleset_extra_100(), receive_packet_ruleset_extra_flag_100(), receive_packet_ruleset_game_100(), receive_packet_ruleset_goods_100(), receive_packet_ruleset_government_100(), receive_packet_ruleset_government_ruler_title_100(), receive_packet_ruleset_impr_flag_100(), receive_packet_ruleset_multiplier_100(), receive_packet_ruleset_music_100(), receive_packet_ruleset_nation_100(), receive_packet_ruleset_nation_groups_100(), receive_packet_ruleset_nation_sets_100(), receive_packet_ruleset_resource_100(), receive_packet_ruleset_road_100(), receive_packet_ruleset_select_100(), receive_packet_ruleset_specialist_100(), receive_packet_ruleset_style_100(), receive_packet_ruleset_summary_100(), receive_packet_ruleset_tech_100(), receive_packet_ruleset_tech_class_100(), receive_packet_ruleset_tech_flag_100(), receive_packet_ruleset_terrain_100(), receive_packet_ruleset_terrain_control_100(), receive_packet_ruleset_terrain_flag_100(), receive_packet_ruleset_trade_100(), receive_packet_ruleset_unit_100(), receive_packet_ruleset_unit_bonus_100(), receive_packet_ruleset_unit_class_100(), receive_packet_ruleset_unit_class_flag_100(), receive_packet_ruleset_unit_flag_100(), receive_packet_save_scenario_100(), receive_packet_scenario_description_100(), receive_packet_scenario_info_100(), receive_packet_server_info_100(), receive_packet_server_setting_bitwise_100(), receive_packet_server_setting_bool_100(), receive_packet_server_setting_const_100(), receive_packet_server_setting_control_100(), receive_packet_server_setting_enum_100(), receive_packet_server_setting_int_100(), receive_packet_server_setting_str_100(), receive_packet_set_topology_100(), receive_packet_single_want_hack_reply_100(), receive_packet_single_want_hack_req_100(), receive_packet_spaceship_info_100(), receive_packet_spaceship_place_100(), receive_packet_start_phase_100(), receive_packet_team_name_info_100(), receive_packet_tile_info_100(), receive_packet_timeout_info_100(), receive_packet_trade_route_info_100(), receive_packet_unit_action_answer_100(), receive_packet_unit_action_query_100(), receive_packet_unit_actions_100(), receive_packet_unit_change_activity_100(), receive_packet_unit_combat_info_100(), receive_packet_unit_do_action_100(), receive_packet_unit_get_actions_100(), receive_packet_unit_info_100(), receive_packet_unit_orders_100(), receive_packet_unit_remove_100(), receive_packet_unit_server_side_agent_set_100(), receive_packet_unit_short_info_100(), receive_packet_unit_sscs_set_100(), receive_packet_unit_type_upgrade_100(), receive_packet_unknown_research_100(), receive_packet_vote_new_100(), receive_packet_vote_remove_100(), receive_packet_vote_resolve_100(), receive_packet_vote_update_100(), receive_packet_web_city_info_addition_100(), receive_packet_web_cma_clear_100(), receive_packet_web_cma_set_100(), receive_packet_web_player_info_addition_100(), receive_packet_web_ruleset_unit_addition_100(), receive_packet_worker_task_100(), send_packet_achievement_info_100(), send_packet_authentication_reply_100(), send_packet_authentication_req_100(), send_packet_calendar_info_100(), send_packet_chat_msg_100(), send_packet_chat_msg_req_100(), send_packet_city_buy_100(), send_packet_city_change_100(), send_packet_city_change_specialist_100(), send_packet_city_info_100(), send_packet_city_make_specialist_100(), send_packet_city_make_worker_100(), send_packet_city_name_suggestion_info_100(), send_packet_city_name_suggestion_req_100(), send_packet_city_nationalities_100(), send_packet_city_options_req_100(), send_packet_city_rally_point_100(), send_packet_city_refresh_100(), send_packet_city_remove_100(), send_packet_city_rename_100(), send_packet_city_sabotage_list_100(), send_packet_city_sell_100(), send_packet_city_short_info_100(), send_packet_city_update_counters_100(), send_packet_city_worklist_100(), send_packet_client_info_100(), send_packet_conn_info_100(), send_packet_conn_ping_info_100(), send_packet_connect_msg_100(), send_packet_diplomacy_accept_treaty_100(), send_packet_diplomacy_accept_treaty_req_100(), send_packet_diplomacy_cancel_meeting_100(), send_packet_diplomacy_cancel_meeting_req_100(), send_packet_diplomacy_cancel_pact_100(), send_packet_diplomacy_create_clause_100(), send_packet_diplomacy_create_clause_req_100(), send_packet_diplomacy_init_meeting_100(), send_packet_diplomacy_init_meeting_req_100(), send_packet_diplomacy_remove_clause_100(), send_packet_diplomacy_remove_clause_req_100(), send_packet_early_chat_msg_100(), send_packet_edit_city_100(), send_packet_edit_city_create_100(), send_packet_edit_city_remove_100(), send_packet_edit_game_100(), send_packet_edit_mode_100(), send_packet_edit_object_created_100(), send_packet_edit_player_100(), send_packet_edit_player_create_100(), send_packet_edit_player_remove_100(), send_packet_edit_player_vision_100(), send_packet_edit_scenario_desc_100(), send_packet_edit_tile_100(), send_packet_edit_tile_extra_100(), send_packet_edit_tile_terrain_100(), send_packet_edit_toggle_fogofwar_100(), send_packet_edit_unit_100(), send_packet_edit_unit_create_100(), send_packet_edit_unit_remove_100(), send_packet_edit_unit_remove_by_id_100(), send_packet_game_info_100(), send_packet_game_load_100(), send_packet_investigate_finished_100(), send_packet_investigate_started_100(), send_packet_map_info_100(), send_packet_nation_availability_100(), send_packet_nation_select_req_100(), send_packet_new_year_100(), send_packet_nuke_tile_info_100(), send_packet_page_msg_100(), send_packet_page_msg_part_100(), send_packet_play_music_100(), send_packet_player_attribute_chunk_100(), send_packet_player_change_government_100(), send_packet_player_diplstate_100(), send_packet_player_info_100(), send_packet_player_multiplier_100(), send_packet_player_phase_done_100(), send_packet_player_place_infra_100(), send_packet_player_rates_100(), send_packet_player_ready_100(), send_packet_player_remove_100(), send_packet_player_research_100(), send_packet_player_tech_goal_100(), send_packet_popup_image_100(), send_packet_report_req_100(), send_packet_research_info_100(), send_packet_ruleset_achievement_100(), send_packet_ruleset_action_100(), send_packet_ruleset_action_auto_100(), send_packet_ruleset_action_enabler_100(), send_packet_ruleset_base_100(), send_packet_ruleset_building_100(), send_packet_ruleset_choices_100(), send_packet_ruleset_city_100(), send_packet_ruleset_clause_100(), send_packet_ruleset_control_100(), send_packet_ruleset_counter_100(), send_packet_ruleset_description_part_100(), send_packet_ruleset_disaster_100(), send_packet_ruleset_effect_100(), send_packet_ruleset_extra_100(), send_packet_ruleset_extra_flag_100(), send_packet_ruleset_game_100(), send_packet_ruleset_goods_100(), send_packet_ruleset_government_100(), send_packet_ruleset_government_ruler_title_100(), send_packet_ruleset_impr_flag_100(), send_packet_ruleset_multiplier_100(), send_packet_ruleset_music_100(), send_packet_ruleset_nation_100(), send_packet_ruleset_nation_groups_100(), send_packet_ruleset_nation_sets_100(), send_packet_ruleset_resource_100(), send_packet_ruleset_road_100(), send_packet_ruleset_select_100(), send_packet_ruleset_specialist_100(), send_packet_ruleset_style_100(), send_packet_ruleset_summary_100(), send_packet_ruleset_tech_100(), send_packet_ruleset_tech_class_100(), send_packet_ruleset_tech_flag_100(), send_packet_ruleset_terrain_100(), send_packet_ruleset_terrain_control_100(), send_packet_ruleset_terrain_flag_100(), send_packet_ruleset_trade_100(), send_packet_ruleset_unit_100(), send_packet_ruleset_unit_bonus_100(), send_packet_ruleset_unit_class_100(), send_packet_ruleset_unit_class_flag_100(), send_packet_ruleset_unit_flag_100(), send_packet_save_scenario_100(), send_packet_scenario_description_100(), send_packet_scenario_info_100(), send_packet_server_info_100(), send_packet_server_setting_bitwise_100(), send_packet_server_setting_bool_100(), send_packet_server_setting_const_100(), send_packet_server_setting_control_100(), send_packet_server_setting_enum_100(), send_packet_server_setting_int_100(), send_packet_server_setting_str_100(), send_packet_set_topology_100(), send_packet_single_want_hack_reply_100(), send_packet_single_want_hack_req_100(), send_packet_spaceship_info_100(), send_packet_spaceship_place_100(), send_packet_start_phase_100(), send_packet_team_name_info_100(), send_packet_tile_info_100(), send_packet_timeout_info_100(), send_packet_trade_route_info_100(), send_packet_unit_action_answer_100(), send_packet_unit_action_query_100(), send_packet_unit_actions_100(), send_packet_unit_change_activity_100(), send_packet_unit_combat_info_100(), send_packet_unit_do_action_100(), send_packet_unit_get_actions_100(), send_packet_unit_info_100(), send_packet_unit_orders_100(), send_packet_unit_remove_100(), send_packet_unit_server_side_agent_set_100(), send_packet_unit_short_info_100(), send_packet_unit_sscs_set_100(), send_packet_unit_type_upgrade_100(), send_packet_unknown_research_100(), send_packet_vote_new_100(), send_packet_vote_remove_100(), send_packet_vote_resolve_100(), send_packet_vote_update_100(), send_packet_web_city_info_addition_100(), send_packet_web_cma_clear_100(), send_packet_web_cma_set_100(), send_packet_web_player_info_addition_100(), send_packet_web_ruleset_unit_addition_100(), and send_packet_worker_task_100().

## ◆ genhash_new_nbuckets()

static struct genhash * genhash_new_nbuckets | ( | genhash_val_fn_t | key_val_func,
|  | genhash_comp_fn_t | key_comp_func,
|  | genhash_copy_fn_t | key_copy_func,
|  | genhash_free_fn_t | key_free_func,
|  | genhash_copy_fn_t | data_copy_func,
|  | genhash_free_fn_t | data_free_func,
|  | size_t | num_buckets
| ) |  |

static

Internal constructor, specifying exact number of buckets. Allows to specify functions to free the memory allocated for the key and user-data that get called when removing the bucket from the hash table or changing key/user-data values.

NB: Be sure to check the "copy constructor" genhash_copy() if you change this function significantly.

Definition at line 202 of file genhash.c.

Referenced by genhash_new(), genhash_new_full(), genhash_new_nentries(), and genhash_new_nentries_full().

## ◆ genhash_new_nentries()

struct genhash * genhash_new_nentries | ( | genhash_val_fn_t | key_val_func,
|  | genhash_comp_fn_t | key_comp_func,
|  | size_t | nentries
| ) |  |

Constructor specifying number of entries.

Definition at line 253 of file genhash.c.

## ◆ genhash_new_nentries_full()

struct genhash * genhash_new_nentries_full | ( | genhash_val_fn_t | key_val_func,
|  | genhash_comp_fn_t | key_comp_func,
|  | genhash_copy_fn_t | key_copy_func,
|  | genhash_free_fn_t | key_free_func,
|  | genhash_copy_fn_t | data_copy_func,
|  | genhash_free_fn_t | data_free_func,
|  | size_t | nentries
| ) |  |

Constructor specifying number of entries. Allows to specify functions to free the memory allocated for the key and user-data that get called when removing the bucket from the hash table or changing key/user-data values.

Definition at line 236 of file genhash.c.

Referenced by _hash_new_nentries_full().

## ◆ genhash_remove()

bool genhash_remove | ( | struct genhash * | pgenhash,
|  | const void * | key
| ) |  |

Delete an entry from the genhash table. Returns TRUE on success.

Definition at line 702 of file genhash.c.

Referenced by _hash_remove(), receive_packet_city_info_100(), receive_packet_city_remove_100(), receive_packet_city_short_info_100(), receive_packet_player_remove_100(), receive_packet_unit_info_100(), receive_packet_unit_remove_100(), receive_packet_unit_short_info_100(), receive_packet_unknown_research_100(), receive_packet_web_city_info_addition_100(), send_packet_city_info_100(), send_packet_city_remove_100(), send_packet_city_short_info_100(), send_packet_player_remove_100(), send_packet_unit_info_100(), send_packet_unit_remove_100(), send_packet_unit_short_info_100(), send_packet_unknown_research_100(), and send_packet_web_city_info_addition_100().

## ◆ genhash_remove_full()

bool genhash_remove_full | ( | struct genhash * | pgenhash,
|  | const void * | key,
|  | void ** | deleted_pkey,
|  | void ** | deleted_pdata
| ) |  |

Delete an entry from the genhash table. Returns TRUE on success.

Returns in 'deleted_pkey' and 'deleted_pdata' the old contents of the deleted entry if not NULL. NB: It can returns freed pointers if free functions were supplied to the genhash table.

Definition at line 714 of file genhash.c.

Referenced by _hash_remove_full(), and genhash_remove().

## ◆ genhash_replace()

bool genhash_replace | ( | struct genhash * | pgenhash,
|  | const void * | key,
|  | const void * | data
| ) |  |

Insert entry, replacing any existing entry which has the same key. Returns TRUE if a data have been replaced, FALSE if it was a simple insertion.

Definition at line 632 of file genhash.c.

Referenced by _hash_replace().

## ◆ genhash_replace_full()

bool genhash_replace_full | ( | struct genhash * | pgenhash,
|  | const void * | key,
|  | const void * | data,
|  | void ** | old_pkey,
|  | void ** | old_pdata
| ) |  |

Insert entry, replacing any existing entry which has the same key. Returns TRUE if a data have been replaced, FALSE if it was a simple insertion.

Returns in 'old_pkey' and 'old_pdata' the old content of the bucket if they are not NULL. NB: It can returns freed pointers if free functions were supplied to the genhash table.

Definition at line 647 of file genhash.c.

Referenced by _hash_replace_full(), and genhash_replace().

## ◆ genhash_resize_table()

static void genhash_resize_table | ( | struct genhash * | pgenhash,
|  | size_t | new_nbuckets
| ) |  |

static

Resize the genhash table: relink entries.

Definition at line 305 of file genhash.c.

Referenced by genhash_maybe_resize().

## ◆ genhash_set_no_shrink()

bool genhash_set_no_shrink | ( | struct genhash * | pgenhash,
|  | bool | no_shrink
| ) |  |

Prevent or allow the genhash table automatically shrinking. Returns the old value of the setting.

Definition at line 512 of file genhash.c.

Referenced by _hash_set_no_shrink().

## ◆ genhash_size()

size_t genhash_size | ( | const struct genhash * | pgenhash | ) |

Returns the number of entries in the genhash table.

Definition at line 525 of file genhash.c.

Referenced by _hash_size().

## ◆ genhash_slot_create()

static void genhash_slot_create | ( | struct genhash * | pgenhash,
|  | struct genhash_entry ** | slot,
|  | const void * | key,
|  | const void * | data,
|  | genhash_val_t | hash_val
| ) |  |

inlinestatic

Create the entry and call the copy callbacks.

Definition at line 453 of file genhash.c.

Referenced by genhash_copy(), genhash_insert(), and genhash_replace_full().

## ◆ genhash_slot_free()

static void genhash_slot_free | ( | struct genhash * | pgenhash,
|  | struct genhash_entry ** | slot
| ) |  |

inlinestatic

Free the entry slot and call the free callbacks.

Definition at line 472 of file genhash.c.

Referenced by genhash_clear(), and genhash_remove_full().

## ◆ genhash_slot_get()

static void genhash_slot_get | ( | struct genhash_entry *const * | slot,
|  | void ** | pkey,
|  | void ** | data
| ) |  |

inlinestatic

Function to store data.

Definition at line 437 of file genhash.c.

Referenced by genhash_lookup(), genhash_remove_full(), and genhash_replace_full().

## ◆ genhash_slot_lookup()

static struct genhash_entry ** genhash_slot_lookup | ( | const struct genhash * | pgenhash,
|  | const void * | key,
|  | genhash_val_t | hash_val
| ) |  |

inlinestatic

Return slot (entry pointer) in genhash table where key resides, or where it should go if it is to be a new key.

Definition at line 396 of file genhash.c.

Referenced by genhash_insert(), genhash_lookup(), genhash_remove_full(), genhash_replace_full(), and genhashes_are_equal_full().

## ◆ genhash_slot_set()

static void genhash_slot_set | ( | struct genhash * | pgenhash,
|  | struct genhash_entry ** | slot,
|  | const void * | key,
|  | const void * | data
| ) |  |

inlinestatic

Clear previous values (with free callback) and call the copy callbacks.

Definition at line 490 of file genhash.c.

Referenced by genhash_replace_full().

## ◆ genhash_str_comp_func()

bool genhash_str_comp_func | ( | const char * | vkey1,
|  | const char * | vkey2
| ) |  |

A supplied function for comparison of nul-terminated strings:

Definition at line 124 of file genhash.c.

## ◆ genhash_str_copy_func()

char * genhash_str_copy_func | ( | const char * | vkey | ) |

Copy function for string allocation.

Definition at line 132 of file genhash.c.

## ◆ genhash_str_free_func()

void genhash_str_free_func | ( | char * | vkey | ) |

Free function for string allocation.

Definition at line 140 of file genhash.c.

## ◆ genhash_str_val_func()

genhash_val_t genhash_str_val_func | ( | const char * | vkey | ) |

A supplied genhash function appropriate to nul-terminated strings. Prefers table sizes that are prime numbers.

Definition at line 109 of file genhash.c.

## ◆ genhash_val_calc()

static genhash_val_t genhash_val_calc | ( | const struct genhash * | pgenhash,
|  | const void * | key
| ) |  |

inlinestatic

Calculate genhash value given hash table and key.

Definition at line 381 of file genhash.c.

Referenced by genhash_insert(), genhash_lookup(), genhash_remove_full(), and genhash_replace_full().

## ◆ genhash_value_iter_init()

struct iterator * genhash_value_iter_init | ( | struct genhash_iter * | iter,
|  | const struct genhash * | pgenhash
| ) |  |

Returns an iterator over the hash table's values.

Definition at line 909 of file genhash.c.

Referenced by _hash_value_iter_init().

## ◆ genhashes_are_equal()

bool genhashes_are_equal | ( | const struct genhash * | pgenhash1,
|  | const struct genhash * | pgenhash2
| ) |  |

Returns TRUE iff the hash tables contains the same pairs of key/data.

Definition at line 741 of file genhash.c.

## ◆ genhashes_are_equal_full()

bool genhashes_are_equal_full | ( | const struct genhash * | pgenhash1,
|  | const struct genhash * | pgenhash2,
|  | genhash_comp_fn_t | data_comp_func
| ) |  |

Returns TRUE iff the hash tables contains the same pairs of key/data.

Definition at line 750 of file genhash.c.

Referenced by _hashes_are_equal_full(), and genhashes_are_equal().