diff options
72 files changed, 465 insertions, 465 deletions
diff --git a/epan/conversation_table.c b/epan/conversation_table.c index 304717d8a0..07ac311209 100644 --- a/epan/conversation_table.c +++ b/epan/conversation_table.c @@ -140,7 +140,7 @@ register_conversation_table(const int proto_id, gboolean hide_ports, tap_packet_ } /* Set GUI fields for register_ct list */ -static gboolean +static bool set_conv_gui_data(const void *key _U_, void *value, void *userdata) { GString *conv_cmd_str = g_string_new("conv,"); @@ -166,7 +166,7 @@ void conversation_table_set_gui_info(conv_gui_init_cb init_cb) wmem_tree_foreach(registered_ct_tables, set_conv_gui_data, (void*)init_cb); } -static gboolean +static bool set_endpoint_gui_data(const void *key _U_, void *value, void *userdata) { stat_tap_ui ui_info; diff --git a/epan/dissectors/asn1/kerberos/packet-kerberos-template.c b/epan/dissectors/asn1/kerberos/packet-kerberos-template.c index c59fac7a5a..715cf78287 100644 --- a/epan/dissectors/asn1/kerberos/packet-kerberos-template.c +++ b/epan/dissectors/asn1/kerberos/packet-kerberos-template.c @@ -492,7 +492,7 @@ wmem_map_t *kerberos_longterm_keys = NULL; static wmem_map_t *kerberos_all_keys = NULL; static wmem_map_t *kerberos_app_session_keys = NULL; -static gboolean +static bool enc_key_list_cb(wmem_allocator_t* allocator _U_, wmem_cb_event_t event _U_, void *user_data _U_) { enc_key_list = NULL; diff --git a/epan/dissectors/packet-aeron.c b/epan/dissectors/packet-aeron.c index 82d6a8eaf4..1c34a864f7 100644 --- a/epan/dissectors/packet-aeron.c +++ b/epan/dissectors/packet-aeron.c @@ -1998,7 +1998,7 @@ static void aeron_msg_fragment_add(aeron_msg_t * msg, aeron_msg_fragment_t * fra } } -static gboolean aeron_msg_process_orphan_fragments_msg_cb(const void *key _U_, void * value, void * userdata) +static bool aeron_msg_process_orphan_fragments_msg_cb(const void *key _U_, void * value, void * userdata) { aeron_msg_t * msg = (aeron_msg_t *) value; aeron_term_t * term = (aeron_term_t *) userdata; diff --git a/epan/dissectors/packet-blip.c b/epan/dissectors/packet-blip.c index 77130e1189..6159abb4a4 100644 --- a/epan/dissectors/packet-blip.c +++ b/epan/dissectors/packet-blip.c @@ -258,7 +258,7 @@ get_blip_conversation(packet_info* pinfo) #ifdef HAVE_ZLIB -static gboolean +static bool z_stream_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { z_stream *decompress_stream = (z_stream *)user_data; diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c index 941d86b4a8..3ee66c3d82 100644 --- a/epan/dissectors/packet-diameter.c +++ b/epan/dissectors/packet-diameter.c @@ -1398,9 +1398,9 @@ dissect_diameter_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi /* Load header fields if not already done */ if (hf_diameter_code == -1) proto_registrar_get_byname("diameter.code"); - col_set_str(pinfo->cinfo, COL_PROTOCOL, "DIAMETER"); + if (have_tap_listener(exported_pdu_tap)){ export_diameter_pdu(pinfo,tvb); } @@ -2032,7 +2032,7 @@ strcase_equal(gconstpointer ka, gconstpointer kb) return g_ascii_strcasecmp(a,b) == 0; } -static gboolean +static bool ddict_cleanup_cb(wmem_allocator_t* allocator _U_, wmem_cb_event_t event _U_, void *user_data) { ddict_t *d = (ddict_t *)user_data; diff --git a/epan/dissectors/packet-dof.c b/epan/dissectors/packet-dof.c index 6ec74e3489..bbf086061a 100644 --- a/epan/dissectors/packet-dof.c +++ b/epan/dissectors/packet-dof.c @@ -2401,7 +2401,7 @@ static const value_string dof_2008_16_security_12_m[] = { static int hf_security_12_count = -1; static int hf_security_12_permission_group_identifier = -1; -static gboolean +static bool dof_sessions_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { ccm_session_data *ccm_data = (ccm_session_data*) user_data; diff --git a/epan/dissectors/packet-epl-profile-parser.c b/epan/dissectors/packet-epl-profile-parser.c index b4adc42458..61a7df8706 100644 --- a/epan/dissectors/packet-epl-profile-parser.c +++ b/epan/dissectors/packet-epl-profile-parser.c @@ -597,7 +597,7 @@ epl_xdd_load(struct profile *profile _U_, const char *xml_file _U_) */ -static gboolean +static bool free_garray(wmem_allocator_t *scope _U_, wmem_cb_event_t event _U_, void *data) { GArray *arr = (GArray*)data; diff --git a/epan/dissectors/packet-epl.c b/epan/dissectors/packet-epl.c index 0e933ca639..2a4830d972 100644 --- a/epan/dissectors/packet-epl.c +++ b/epan/dissectors/packet-epl.c @@ -1920,7 +1920,7 @@ static wmem_map_t *epl_profiles_by_device, *epl_profiles_by_nodeid, *epl_profile static struct profile *epl_default_profile; static const char *epl_default_profile_path = NULL, *epl_default_profile_path_last = NULL; -static gboolean +static bool profile_del_cb(wmem_allocator_t *pool _U_, wmem_cb_event_t event _U_, void *_profile) { struct profile *profile = (struct profile*)_profile; diff --git a/epan/dissectors/packet-http2.c b/epan/dissectors/packet-http2.c index 7104e63fa8..3bea95fd3e 100644 --- a/epan/dissectors/packet-http2.c +++ b/epan/dissectors/packet-http2.c @@ -1377,7 +1377,7 @@ select_http2_flow_index(packet_info *pinfo, http2_session_t *h2session) } #ifdef HAVE_NGHTTP2 -static gboolean +static bool hd_inflate_del_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { nghttp2_hd_inflate_del((nghttp2_hd_inflater*)user_data); diff --git a/epan/dissectors/packet-kerberos.c b/epan/dissectors/packet-kerberos.c index 85d5036af2..5ea93d2007 100644 --- a/epan/dissectors/packet-kerberos.c +++ b/epan/dissectors/packet-kerberos.c @@ -923,7 +923,7 @@ wmem_map_t *kerberos_longterm_keys = NULL; static wmem_map_t *kerberos_all_keys = NULL; static wmem_map_t *kerberos_app_session_keys = NULL; -static gboolean +static bool enc_key_list_cb(wmem_allocator_t* allocator _U_, wmem_cb_event_t event _U_, void *user_data _U_) { enc_key_list = NULL; diff --git a/epan/dissectors/packet-lbtrm.c b/epan/dissectors/packet-lbtrm.c index a03e1e064e..0c1a848bc7 100644 --- a/epan/dissectors/packet-lbtrm.c +++ b/epan/dissectors/packet-lbtrm.c @@ -1072,7 +1072,7 @@ typedef struct guint32 current_frame; } lbtrm_sqn_frame_list_callback_data_t; -static gboolean dissect_lbtrm_sqn_frame_list_callback(const void *key _U_, void * frame, void * user_data) +static bool dissect_lbtrm_sqn_frame_list_callback(const void *key _U_, void * frame, void * user_data) { lbtrm_sqn_frame_list_callback_data_t * cb_data = (lbtrm_sqn_frame_list_callback_data_t *) user_data; proto_item * transport_item = NULL; diff --git a/epan/dissectors/packet-lbtru.c b/epan/dissectors/packet-lbtru.c index 9c0e0c322e..a47d6b28d3 100644 --- a/epan/dissectors/packet-lbtru.c +++ b/epan/dissectors/packet-lbtru.c @@ -1075,7 +1075,7 @@ typedef struct guint32 current_frame; } lbtru_sqn_frame_list_callback_data_t; -static gboolean dissect_lbtru_sqn_frame_list_callback(const void *key _U_, void * frame, void * user_data) +static bool dissect_lbtru_sqn_frame_list_callback(const void *key _U_, void * frame, void * user_data) { lbtru_sqn_frame_list_callback_data_t * cb_data = (lbtru_sqn_frame_list_callback_data_t *) user_data; proto_item * transport_item = NULL; diff --git a/epan/dissectors/packet-ntlmssp.c b/epan/dissectors/packet-ntlmssp.c index 0f0840b36c..4d1db0b325 100644 --- a/epan/dissectors/packet-ntlmssp.c +++ b/epan/dissectors/packet-ntlmssp.c @@ -370,7 +370,7 @@ LEBE_Convert(int value) } #endif -static gboolean +static bool ntlmssp_sessions_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data _U_) { ntlmssp_info * conv_ntlmssp_info = (ntlmssp_info *) user_data; diff --git a/epan/dissectors/packet-rtp.c b/epan/dissectors/packet-rtp.c index 8d1dde65ea..a7c55a1ee6 100644 --- a/epan/dissectors/packet-rtp.c +++ b/epan/dissectors/packet-rtp.c @@ -748,7 +748,7 @@ rtp_dyn_payloads_table_steal_func(gpointer key _U_, gpointer value, gpointer use /* the following is used as the wmem callback to destroy *all* alive rtp_dyn_payload_t's, which are pointed to by the single rtp_dyn_payloads GHashTable above. */ -static gboolean +static bool wmem_rtp_dyn_payload_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data _U_) { diff --git a/epan/dissectors/packet-smb2.c b/epan/dissectors/packet-smb2.c index adafc493cb..612d6fedf2 100644 --- a/epan/dissectors/packet-smb2.c +++ b/epan/dissectors/packet-smb2.c @@ -1507,7 +1507,7 @@ smb2_fid_info_hash(gconstpointer k) /* Callback for destroying the glib hash tables associated with a conversation * struct. */ -static gboolean +static bool smb2_conv_destroy(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { diff --git a/epan/dissectors/packet-spdy.c b/epan/dissectors/packet-spdy.c index cfbfae0127..98eb435d12 100644 --- a/epan/dissectors/packet-spdy.c +++ b/epan/dissectors/packet-spdy.c @@ -432,7 +432,7 @@ static const char spdy_dictionary[] = { * streams to avoid memory leaks. * XXX: can we be more aggressive and call this sooner for finished streams? */ -static gboolean inflate_end_cb (wmem_allocator_t *allocator _U_, +static bool inflate_end_cb (wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { inflateEnd((z_streamp)user_data); diff --git a/epan/dissectors/packet-tls-utils.c b/epan/dissectors/packet-tls-utils.c index 5b82f5d093..880ed2dea1 100644 --- a/epan/dissectors/packet-tls-utils.c +++ b/epan/dissectors/packet-tls-utils.c @@ -3962,7 +3962,7 @@ ssl_change_cipher(SslDecryptSession *ssl_session, gboolean server) /* }}} */ /* Init cipher state given some security parameters. {{{ */ -static gboolean +static bool ssl_decoder_destroy_cb(wmem_allocator_t *, wmem_cb_event_t, void *); static SslDecoder* @@ -4004,7 +4004,7 @@ ssl_create_decoder(const SslCipherSuite *cipher_suite, gint cipher_algo, return dec; } -static gboolean +static bool ssl_decoder_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { SslDecoder *dec = (SslDecoder *) user_data; @@ -4020,7 +4020,7 @@ ssl_decoder_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U return FALSE; } -static gboolean +static bool tls13_cipher_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { tls13_cipher *cipher = (tls13_cipher *) user_data; diff --git a/epan/dissectors/packet-wireguard.c b/epan/dissectors/packet-wireguard.c index d6a2b3fc98..3e7a22490e 100644 --- a/epan/dissectors/packet-wireguard.c +++ b/epan/dissectors/packet-wireguard.c @@ -458,7 +458,7 @@ wg_create_cipher(const wg_qqword *key) return hd; } -static gboolean +static bool wg_handshake_state_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { wg_handshake_state_t *hs = (wg_handshake_state_t *)user_data; diff --git a/epan/prefs.c b/epan/prefs.c index 2ff177ec86..08a9ab3a96 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -827,7 +827,7 @@ typedef struct { gboolean skip_obsolete; } call_foreach_t; -static gboolean +static bool call_foreach_cb(const void *key _U_, void *value, void *data) { module_t *module = (module_t*)value; @@ -904,7 +904,7 @@ prefs_modules_foreach_submodules(module_t *module, module_cb callback, return prefs_module_list_foreach((module)?module->submodules:prefs_top_level_modules, callback, user_data, TRUE); } -static gboolean +static bool call_apply_cb(const void *key _U_, void *value, void *data _U_) { module_t *module = (module_t *)value; @@ -1073,7 +1073,7 @@ preference_match(gconstpointer a, gconstpointer b) return strcmp(name, pref->name); } -static gboolean +static bool module_find_pref_cb(const void *key _U_, void *value, void *data) { find_pref_arg_t* arg = (find_pref_arg_t*)data; @@ -4308,7 +4308,7 @@ reset_pref_cb(gpointer data, gpointer user_data) /* * Reset all preferences for a module. */ -static gboolean +static bool reset_module_prefs(const void *key _U_, void *value, void *data _U_) { module_t *module = (module_t *)value; diff --git a/epan/tvbparse.c b/epan/tvbparse.c index bc4ed264db..aaaa6aa00a 100644 --- a/epan/tvbparse.c +++ b/epan/tvbparse.c @@ -429,7 +429,7 @@ static int cond_one_of(tvbparse_t* tt, const int offset, const tvbparse_wanted_t return -1; } -static gboolean +static bool tvbparse_wanted_cleanup_cb(wmem_allocator_t* allocator _U_, wmem_cb_event_t event _U_, void *user_data) { tvbparse_wanted_t* w = (tvbparse_wanted_t *)user_data; diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c index f7a02ce30e..981ffe089b 100644 --- a/epan/wslua/init_wslua.c +++ b/epan/wslua/init_wslua.c @@ -141,7 +141,7 @@ static expert_field ei_lua_proto_deprecated_error = EI_INIT; static gint ett_wslua_traceback = -1; -static gboolean +static bool lua_pinfo_end(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data _U_) { diff --git a/sharkd_session.c b/sharkd_session.c index a71d2f5596..d03882f421 100644 --- a/sharkd_session.c +++ b/sharkd_session.c @@ -788,7 +788,7 @@ fail: return ret; } -static gboolean +static bool sharkd_session_process_info_nstat_cb(const void *key, void *value, void *userdata _U_) { stat_tap_table_ui *stat_tap = (stat_tap_table_ui *) value; @@ -801,7 +801,7 @@ sharkd_session_process_info_nstat_cb(const void *key, void *value, void *userdat return FALSE; } -static gboolean +static bool sharkd_session_process_info_conv_cb(const void* key, void* value, void* userdata _U_) { struct register_ct *table = (struct register_ct *) value; @@ -826,7 +826,7 @@ sharkd_session_process_info_conv_cb(const void* key, void* value, void* userdata return FALSE; } -static gboolean +static bool sharkd_session_seq_analysis_cb(const void *key, void *value, void *userdata _U_) { register_analysis_t *analysis = (register_analysis_t *) value; @@ -839,7 +839,7 @@ sharkd_session_seq_analysis_cb(const void *key, void *value, void *userdata _U_) return FALSE; } -static gboolean +static bool sharkd_export_object_visit_cb(const void *key _U_, void *value, void *user_data _U_) { register_eo_t *eo = (register_eo_t *) value; @@ -856,7 +856,7 @@ sharkd_export_object_visit_cb(const void *key _U_, void *value, void *user_data return FALSE; } -static gboolean +static bool sharkd_srt_visit_cb(const void *key _U_, void *value, void *user_data _U_) { register_srt_t *srt = (register_srt_t *) value; @@ -873,7 +873,7 @@ sharkd_srt_visit_cb(const void *key _U_, void *value, void *user_data _U_) return FALSE; } -static gboolean +static bool sharkd_rtd_visit_cb(const void *key _U_, void *value, void *user_data _U_) { register_rtd_t *rtd = (register_rtd_t *) value; @@ -890,7 +890,7 @@ sharkd_rtd_visit_cb(const void *key _U_, void *value, void *user_data _U_) return FALSE; } -static gboolean +static bool sharkd_follower_visit_cb(const void *key _U_, void *value, void *user_data _U_) { register_follow_t *follower = (register_follow_t *) value; @@ -3516,7 +3516,7 @@ sharkd_session_process_frame_cb_tree(const char *key, epan_dissect_t *edt, proto sharkd_json_array_close(); } -static gboolean +static bool sharkd_follower_visit_layers_cb(const void *key _U_, void *value, void *user_data) { register_follow_t *follower = (register_follow_t *) value; diff --git a/ui/cli/tap-exportobject.c b/ui/cli/tap-exportobject.c index 0a37366447..4a02155c37 100644 --- a/ui/cli/tap-exportobject.c +++ b/ui/cli/tap-exportobject.c @@ -33,7 +33,7 @@ typedef struct _export_object_list_gui_t { static GHashTable* eo_opts = NULL; -static gboolean +static bool list_exportobject_protocol(const void *key, void *value _U_, void *userdata _U_) { fprintf(stderr, " %s\n", (const gchar*)key); diff --git a/ui/cli/tap-flow.c b/ui/cli/tap-flow.c index 44e3be8337..32e0a94f7e 100644 --- a/ui/cli/tap-flow.c +++ b/ui/cli/tap-flow.c @@ -105,7 +105,7 @@ flow_init(const char *opt_argp, void *userdata) } } -static gboolean +static bool flow_register(const void *key _U_, void *value, void *userdata _U_) { register_analysis_t* analysis = (register_analysis_t*)value; diff --git a/ui/cli/tap-follow.c b/ui/cli/tap-follow.c index ed445e23c4..1e0a8c12a3 100644 --- a/ui/cli/tap-follow.c +++ b/ui/cli/tap-follow.c @@ -560,7 +560,7 @@ static void follow_stream(const char *opt_argp, void *userdata) } } -static gboolean +static bool follow_register(const void *key _U_, void *value, void *userdata _U_) { register_follow_t *follower = (register_follow_t*)value; diff --git a/ui/cli/tap-rtd.c b/ui/cli/tap-rtd.c index f81d1357b8..ad56c4c5f2 100644 --- a/ui/cli/tap-rtd.c +++ b/ui/cli/tap-rtd.c @@ -130,7 +130,7 @@ dissector_rtd_init(const char *opt_arg, void* userdata) } /* Set GUI fields for register_rtd list */ -gboolean +bool register_rtd_tables(const void *key _U_, void *value, void *userdata _U_) { register_rtd_t *rtd = (register_rtd_t*)value; diff --git a/ui/cli/tap-simple_stattable.c b/ui/cli/tap-simple_stattable.c index 54235c5954..cca343209d 100644 --- a/ui/cli/tap-simple_stattable.c +++ b/ui/cli/tap-simple_stattable.c @@ -138,7 +138,7 @@ simple_stat_init(const char *opt_arg, void* userdata) init_stat_table(stat_tap, filter); } -gboolean +bool register_simple_stat_tables(const void *key, void *value, void *userdata _U_) { stat_tap_table_ui *stat_tap = (stat_tap_table_ui*)value; diff --git a/ui/cli/tap-srt.c b/ui/cli/tap-srt.c index fee4eceb2b..62cef3af64 100644 --- a/ui/cli/tap-srt.c +++ b/ui/cli/tap-srt.c @@ -157,7 +157,7 @@ dissector_srt_init(const char *opt_arg, void* userdata) } /* Set GUI fields for register_srt list */ -gboolean +bool register_srt_tables(const void *key _U_, void *value, void *userdata _U_) { register_srt_t *srt = (register_srt_t*)value; diff --git a/ui/cli/tshark-tap.h b/ui/cli/tshark-tap.h index a6abd41d23..49b284d1db 100644 --- a/ui/cli/tshark-tap.h +++ b/ui/cli/tshark-tap.h @@ -15,8 +15,8 @@ extern void init_iousers(struct register_ct* ct, const char *filter); extern void init_endpoints(struct register_ct* ct, const char *filter); -extern gboolean register_srt_tables(const void *key, void *value, void *userdata); -extern gboolean register_rtd_tables(const void *key, void *value, void *userdata); -extern gboolean register_simple_stat_tables(const void *key, void *value, void *userdata); +extern bool register_srt_tables(const void *key, void *value, void *userdata); +extern bool register_rtd_tables(const void *key, void *value, void *userdata); +extern bool register_simple_stat_tables(const void *key, void *value, void *userdata); #endif /* __TSHARK_TAP_H__ */ diff --git a/ui/logray/logray_main_window.cpp b/ui/logray/logray_main_window.cpp index 438ccf1605..e038a623a1 100644 --- a/ui/logray/logray_main_window.cpp +++ b/ui/logray/logray_main_window.cpp @@ -2272,7 +2272,7 @@ void LograyMainWindow::initConversationMenus() connect(colorize_action, SIGNAL(triggered()), this, SLOT(colorizeActionTriggered())); } -gboolean LograyMainWindow::addExportObjectsMenuItem(const void *, void *value, void *userdata) +bool LograyMainWindow::addExportObjectsMenuItem(const void *, void *value, void *userdata) { register_eo_t *eo = (register_eo_t*)value; LograyMainWindow *window = (LograyMainWindow*)userdata; diff --git a/ui/logray/logray_main_window.h b/ui/logray/logray_main_window.h index c9073cd333..78b44f5543 100644 --- a/ui/logray/logray_main_window.h +++ b/ui/logray/logray_main_window.h @@ -294,7 +294,7 @@ private slots: void initViewColorizeMenu(); void initConversationMenus(); - static gboolean addExportObjectsMenuItem(const void *key, void *value, void *userdata); + static bool addExportObjectsMenuItem(const void *key, void *value, void *userdata); void initExportObjectsMenus(); // in main_window_slots.cpp diff --git a/ui/qt/response_time_delay_dialog.cpp b/ui/qt/response_time_delay_dialog.cpp index d7618ba456..f656525eeb 100644 --- a/ui/qt/response_time_delay_dialog.cpp +++ b/ui/qt/response_time_delay_dialog.cpp @@ -36,7 +36,7 @@ rtd_init(const char *args, void*) { } } -gboolean register_response_time_delay_tables(const void *, void *value, void*) +bool register_response_time_delay_tables(const void *, void *value, void*) { register_rtd_t *rtd = (register_rtd_t*)value; const char* short_name = proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd))); diff --git a/ui/qt/response_time_delay_dialog.h b/ui/qt/response_time_delay_dialog.h index 307a6010f2..95b0d866df 100644 --- a/ui/qt/response_time_delay_dialog.h +++ b/ui/qt/response_time_delay_dialog.h @@ -49,6 +49,6 @@ private slots: * @param value register_rtd_t* representing dissetor RTD table * @param userdata is unused */ -gboolean register_response_time_delay_tables(const void *key, void *value, void *userdata); +bool register_response_time_delay_tables(const void *key, void *value, void *userdata); #endif // __RESPONSE_TIME_DELAY_DIALOG_H__ diff --git a/ui/qt/sequence_dialog.cpp b/ui/qt/sequence_dialog.cpp index bc8cca1f4c..c81cde4fdd 100644 --- a/ui/qt/sequence_dialog.cpp +++ b/ui/qt/sequence_dialog.cpp @@ -802,7 +802,7 @@ void SequenceDialog::zoomXAxis(bool in) sp->replot(); } -gboolean SequenceDialog::addFlowSequenceItem(const void* key, void *value, void *userdata) +bool SequenceDialog::addFlowSequenceItem(const void* key, void *value, void *userdata) { const char* name = (const char*)key; register_analysis_t* analysis = (register_analysis_t*)value; diff --git a/ui/qt/sequence_dialog.h b/ui/qt/sequence_dialog.h index 46987167aa..8c321907b7 100644 --- a/ui/qt/sequence_dialog.h +++ b/ui/qt/sequence_dialog.h @@ -128,7 +128,7 @@ private: void resetAxes(bool keep_lower = false); void goToAdjacentPacket(bool next); - static gboolean addFlowSequenceItem(const void *key, void *value, void *userdata); + static bool addFlowSequenceItem(const void *key, void *value, void *userdata); void processRtpStream(bool select); QVector<rtpstream_id_t *>getSelectedRtpIds(); diff --git a/ui/qt/service_response_time_dialog.cpp b/ui/qt/service_response_time_dialog.cpp index 22c17f5f49..95bd4801a7 100644 --- a/ui/qt/service_response_time_dialog.cpp +++ b/ui/qt/service_response_time_dialog.cpp @@ -39,7 +39,7 @@ srt_init(const char *args, void*) { } } -gboolean register_service_response_tables(const void *, void *value, void*) +bool register_service_response_tables(const void *, void *value, void*) { register_srt_t *srt = (register_srt_t*)value; const char* short_name = proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt))); diff --git a/ui/qt/service_response_time_dialog.h b/ui/qt/service_response_time_dialog.h index 62c2e4de6a..7830e11fc1 100644 --- a/ui/qt/service_response_time_dialog.h +++ b/ui/qt/service_response_time_dialog.h @@ -69,6 +69,6 @@ private slots: * @param value register_srt_t* representing dissetor SRT table * @param userdata is unused */ -gboolean register_service_response_tables(const void *key, void *value, void *userdata); +bool register_service_response_tables(const void *key, void *value, void *userdata); #endif // __SERVICE_RESPONSE_TIME_DIALOG_H__ diff --git a/ui/qt/simple_statistics_dialog.cpp b/ui/qt/simple_statistics_dialog.cpp index a2d7f11c59..ae7156030c 100644 --- a/ui/qt/simple_statistics_dialog.cpp +++ b/ui/qt/simple_statistics_dialog.cpp @@ -37,7 +37,7 @@ simple_stat_init(const char *args, void*) { } } -gboolean register_simple_stat_tables(const void *key, void *value, void*) { +bool register_simple_stat_tables(const void *key, void *value, void*) { stat_tap_table_ui *stu = (stat_tap_table_ui*)value; cfg_str_to_stu_[stu->cli_string] = stu; diff --git a/ui/qt/simple_statistics_dialog.h b/ui/qt/simple_statistics_dialog.h index 0d60727c21..3f89830874 100644 --- a/ui/qt/simple_statistics_dialog.h +++ b/ui/qt/simple_statistics_dialog.h @@ -52,6 +52,6 @@ private slots: * @param key is tap string * @param value stat_tap_table_ui* representing dissetor stat table */ -gboolean register_simple_stat_tables(const void *key, void *value, void*); +bool register_simple_stat_tables(const void *key, void *value, void*); #endif // __SIMPLE_STATISTICS_DIALOG_H__ diff --git a/ui/qt/widgets/filter_expression_toolbar.cpp b/ui/qt/widgets/filter_expression_toolbar.cpp index 8d9cdae7cd..caf91cfa67 100644 --- a/ui/qt/widgets/filter_expression_toolbar.cpp +++ b/ui/qt/widgets/filter_expression_toolbar.cpp @@ -399,7 +399,7 @@ QMenu * FilterExpressionToolBar::findParentMenu(const QStringList tree, void *fe return Q_NULLPTR; } -gboolean FilterExpressionToolBar::filter_expression_add_action(const void *key _U_, void *value, void *user_data) +bool FilterExpressionToolBar::filter_expression_add_action(const void *key _U_, void *value, void *user_data) { filter_expression_t* fe = (filter_expression_t*)value; struct filter_expression_data* data = (filter_expression_data*)user_data; diff --git a/ui/qt/widgets/filter_expression_toolbar.h b/ui/qt/widgets/filter_expression_toolbar.h index be3793089d..80724a27f1 100644 --- a/ui/qt/widgets/filter_expression_toolbar.h +++ b/ui/qt/widgets/filter_expression_toolbar.h @@ -56,7 +56,7 @@ private: void customMenu(FilterExpressionToolBar * target, QAction * filterAction, const QPoint& pos); - static gboolean filter_expression_add_action(const void *key, void *value, void *user_data); + static bool filter_expression_add_action(const void *key, void *value, void *user_data); static QMenu * findParentMenu(const QStringList tree, void *fed_data, QMenu *parent = Q_NULLPTR); }; diff --git a/ui/qt/widgets/traffic_types_list.cpp b/ui/qt/widgets/traffic_types_list.cpp index 0fe5feba93..30126ef947 100644 --- a/ui/qt/widgets/traffic_types_list.cpp +++ b/ui/qt/widgets/traffic_types_list.cpp @@ -43,7 +43,7 @@ void TrafficTypesRowData::setChecked(bool checked) _checked = checked; } -static gboolean iterateProtocols(const void *key, void *value, void *userdata) +static bool iterateProtocols(const void *key, void *value, void *userdata) { QList<TrafficTypesRowData> * protocols = (QList<TrafficTypesRowData> *)userdata; diff --git a/ui/qt/wireshark_main_window.cpp b/ui/qt/wireshark_main_window.cpp index ce8a4d5fcb..aecee5056d 100644 --- a/ui/qt/wireshark_main_window.cpp +++ b/ui/qt/wireshark_main_window.cpp @@ -2316,7 +2316,7 @@ void WiresharkMainWindow::initConversationMenus() connect(colorize_action, SIGNAL(triggered()), this, SLOT(colorizeActionTriggered())); } -gboolean WiresharkMainWindow::addExportObjectsMenuItem(const void *, void *value, void *userdata) +bool WiresharkMainWindow::addExportObjectsMenuItem(const void *, void *value, void *userdata) { register_eo_t *eo = (register_eo_t*)value; WiresharkMainWindow *window = (WiresharkMainWindow*)userdata; @@ -2337,7 +2337,7 @@ void WiresharkMainWindow::initExportObjectsMenus() eo_iterate_tables(addExportObjectsMenuItem, this); } -gboolean WiresharkMainWindow::addFollowStreamMenuItem(const void *key, void *value, void *userdata) +bool WiresharkMainWindow::addFollowStreamMenuItem(const void *key, void *value, void *userdata) { const char *short_name = (const char*)key; register_follow_t *follow = (register_follow_t*)value; diff --git a/ui/qt/wireshark_main_window.h b/ui/qt/wireshark_main_window.h index 10139d7494..2b12272e2c 100644 --- a/ui/qt/wireshark_main_window.h +++ b/ui/qt/wireshark_main_window.h @@ -317,9 +317,9 @@ private slots: void initViewColorizeMenu(); void initConversationMenus(); - static gboolean addExportObjectsMenuItem(const void *key, void *value, void *userdata); + static bool addExportObjectsMenuItem(const void *key, void *value, void *userdata); void initExportObjectsMenus(); - static gboolean addFollowStreamMenuItem(const void *key, void *value, void *userdata); + static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata); void initFollowStreamMenus(); // in main_window_slots.cpp diff --git a/wsutil/wmem/wmem_allocator.h b/wsutil/wmem/wmem_allocator.h index 4e5194707b..8890054aaa 100644 --- a/wsutil/wmem/wmem_allocator.h +++ b/wsutil/wmem/wmem_allocator.h @@ -41,7 +41,7 @@ struct _wmem_allocator_t { /* Implementation details */ void *private_data; enum _wmem_allocator_type_t type; - gboolean in_scope; + bool in_scope; }; #ifdef __cplusplus diff --git a/wsutil/wmem/wmem_allocator_block.c b/wsutil/wmem/wmem_allocator_block.c index 070d472307..b8a0f59828 100644 --- a/wsutil/wmem/wmem_allocator_block.c +++ b/wsutil/wmem/wmem_allocator_block.c @@ -131,7 +131,7 @@ * extensions for x86 and ppc32 would want a larger alignment than this, but * we don't need to do better than malloc. */ -#define WMEM_ALIGN_AMOUNT (2 * sizeof (gsize)) +#define WMEM_ALIGN_AMOUNT (2 * sizeof (size_t)) #define WMEM_ALIGN_SIZE(SIZE) ((~(WMEM_ALIGN_AMOUNT-1)) & \ ((SIZE) + (WMEM_ALIGN_AMOUNT-1))) @@ -152,25 +152,25 @@ typedef struct _wmem_block_hdr_t { * block and the other chunk header fields are irrelevant. */ typedef struct _wmem_block_chunk_t { - guint32 prev; + uint32_t prev; /* flags */ - guint32 last:1; - guint32 used:1; - guint32 jumbo:1; + uint32_t last:1; + uint32_t used:1; + uint32_t jumbo:1; - guint32 len:29; + uint32_t len:29; } wmem_block_chunk_t; /* Handy macros for navigating the chunks in a block as if they were a * doubly-linked list. */ #define WMEM_CHUNK_PREV(CHUNK) ((CHUNK)->prev \ - ? ((wmem_block_chunk_t*)(((guint8*)(CHUNK)) - (CHUNK)->prev)) \ + ? ((wmem_block_chunk_t*)(((uint8_t*)(CHUNK)) - (CHUNK)->prev)) \ : NULL) #define WMEM_CHUNK_NEXT(CHUNK) ((CHUNK)->last \ ? NULL \ - : ((wmem_block_chunk_t*)(((guint8*)(CHUNK)) + (CHUNK)->len))) + : ((wmem_block_chunk_t*)(((uint8_t*)(CHUNK)) + (CHUNK)->len))) #define WMEM_CHUNK_HEADER_SIZE WMEM_ALIGN_SIZE(sizeof(wmem_block_chunk_t)) @@ -178,14 +178,14 @@ typedef struct _wmem_block_chunk_t { (WMEM_BLOCK_HEADER_SIZE + WMEM_CHUNK_HEADER_SIZE)) /* other handy chunk macros */ -#define WMEM_CHUNK_TO_DATA(CHUNK) ((void*)((guint8*)(CHUNK) + WMEM_CHUNK_HEADER_SIZE)) -#define WMEM_DATA_TO_CHUNK(DATA) ((wmem_block_chunk_t*)((guint8*)(DATA) - WMEM_CHUNK_HEADER_SIZE)) +#define WMEM_CHUNK_TO_DATA(CHUNK) ((void*)((uint8_t*)(CHUNK) + WMEM_CHUNK_HEADER_SIZE)) +#define WMEM_DATA_TO_CHUNK(DATA) ((wmem_block_chunk_t*)((uint8_t*)(DATA) - WMEM_CHUNK_HEADER_SIZE)) #define WMEM_CHUNK_DATA_LEN(CHUNK) ((CHUNK)->len - WMEM_CHUNK_HEADER_SIZE) /* some handy block macros */ #define WMEM_BLOCK_HEADER_SIZE WMEM_ALIGN_SIZE(sizeof(wmem_block_hdr_t)) -#define WMEM_BLOCK_TO_CHUNK(BLOCK) ((wmem_block_chunk_t*)((guint8*)(BLOCK) + WMEM_BLOCK_HEADER_SIZE)) -#define WMEM_CHUNK_TO_BLOCK(CHUNK) ((wmem_block_hdr_t*)((guint8*)(CHUNK) - WMEM_BLOCK_HEADER_SIZE)) +#define WMEM_BLOCK_TO_CHUNK(BLOCK) ((wmem_block_chunk_t*)((uint8_t*)(BLOCK) + WMEM_BLOCK_HEADER_SIZE)) +#define WMEM_CHUNK_TO_BLOCK(CHUNK) ((wmem_block_hdr_t*)((uint8_t*)(CHUNK) - WMEM_BLOCK_HEADER_SIZE)) /* This is what the 'data' section of a chunk contains if it is free. */ typedef struct _wmem_block_free_t { @@ -206,7 +206,7 @@ static int wmem_block_verify_block(wmem_block_hdr_t *block) { int total_free_space = 0; - guint32 total_len; + uint32_t total_len; wmem_block_chunk_t *chunk; chunk = WMEM_BLOCK_TO_CHUNK(block); @@ -567,7 +567,7 @@ wmem_block_split_free_chunk(wmem_block_allocator_t *allocator, wmem_block_chunk_t *extra; wmem_block_free_t *old_blk, *new_blk; size_t aligned_size, available; - gboolean last; + bool last; aligned_size = WMEM_ALIGN_SIZE(size) + WMEM_CHUNK_HEADER_SIZE; @@ -590,8 +590,8 @@ wmem_block_split_free_chunk(wmem_block_allocator_t *allocator, available = chunk->len - aligned_size; /* set new values for chunk */ - chunk->len = (guint32) aligned_size; - chunk->last = FALSE; + chunk->len = (uint32_t) aligned_size; + chunk->last = false; /* with chunk's values set, we can use the standard macro to calculate * the location and size of the new free chunk */ @@ -636,11 +636,11 @@ wmem_block_split_free_chunk(wmem_block_allocator_t *allocator, /* Now that we've copied over the free-list stuff (which may have overlapped * with our new chunk header) we can safely write our new chunk header. */ - extra->len = (guint32) available; + extra->len = (uint32_t) available; extra->last = last; extra->prev = chunk->len; - extra->used = FALSE; - extra->jumbo = FALSE; + extra->used = false; + extra->jumbo = false; /* Correctly update the following chunk's back-pointer */ if (!last) { @@ -659,7 +659,7 @@ wmem_block_split_used_chunk(wmem_block_allocator_t *allocator, { wmem_block_chunk_t *extra; size_t aligned_size, available; - gboolean last; + bool last; aligned_size = WMEM_ALIGN_SIZE(size) + WMEM_CHUNK_HEADER_SIZE; @@ -676,19 +676,19 @@ wmem_block_split_used_chunk(wmem_block_allocator_t *allocator, available = chunk->len - aligned_size; /* set new values for chunk */ - chunk->len = (guint32) aligned_size; - chunk->last = FALSE; + chunk->len = (uint32_t) aligned_size; + chunk->last = false; /* with chunk's values set, we can use the standard macro to calculate * the location and size of the new free chunk */ extra = WMEM_CHUNK_NEXT(chunk); /* set the new values for the chunk */ - extra->len = (guint32) available; + extra->len = (uint32_t) available; extra->last = last; extra->prev = chunk->len; - extra->used = FALSE; - extra->jumbo = FALSE; + extra->used = false; + extra->jumbo = false; /* Correctly update the following chunk's back-pointer */ if (!last) { @@ -745,9 +745,9 @@ wmem_block_init_block(wmem_block_allocator_t *allocator, /* a new block contains one chunk, right at the beginning */ chunk = WMEM_BLOCK_TO_CHUNK(block); - chunk->used = FALSE; - chunk->jumbo = FALSE; - chunk->last = TRUE; + chunk->used = false; + chunk->jumbo = false; + chunk->last = true; chunk->prev = 0; chunk->len = WMEM_BLOCK_SIZE - WMEM_BLOCK_HEADER_SIZE; @@ -788,9 +788,9 @@ wmem_block_alloc_jumbo(wmem_block_allocator_t *allocator, const size_t size) /* the new block contains a single jumbo chunk */ chunk = WMEM_BLOCK_TO_CHUNK(block); - chunk->last = TRUE; - chunk->used = TRUE; - chunk->jumbo = TRUE; + chunk->last = true; + chunk->used = true; + chunk->jumbo = true; chunk->len = 0; chunk->prev = 0; @@ -883,7 +883,7 @@ wmem_block_alloc(void *private_data, const size_t size) wmem_block_cycle_recycler(allocator); /* mark it as used */ - chunk->used = TRUE; + chunk->used = true; /* and return the user's pointer */ return WMEM_CHUNK_TO_DATA(chunk); @@ -903,7 +903,7 @@ wmem_block_free(void *private_data, void *ptr) } /* mark it as unused */ - chunk->used = FALSE; + chunk->used = false; /* merge it with any other free chunks adjacent to it, so that contiguous * free space doesn't get fragmented */ diff --git a/wsutil/wmem/wmem_allocator_block_fast.c b/wsutil/wmem/wmem_allocator_block_fast.c index bdb8c2f75d..02b338039b 100644 --- a/wsutil/wmem/wmem_allocator_block_fast.c +++ b/wsutil/wmem/wmem_allocator_block_fast.c @@ -26,12 +26,12 @@ * extensions for x86 and ppc32 would want a larger alignment than this, but * we don't need to do better than malloc. */ -#define WMEM_ALIGN_AMOUNT (2 * sizeof (gsize)) +#define WMEM_ALIGN_AMOUNT (2 * sizeof (size_t)) #define WMEM_ALIGN_SIZE(SIZE) ((~(WMEM_ALIGN_AMOUNT-1)) & \ ((SIZE) + (WMEM_ALIGN_AMOUNT-1))) -#define WMEM_CHUNK_TO_DATA(CHUNK) ((void*)((guint8*)(CHUNK) + WMEM_CHUNK_HEADER_SIZE)) -#define WMEM_DATA_TO_CHUNK(DATA) ((wmem_block_fast_chunk_t*)((guint8*)(DATA) - WMEM_CHUNK_HEADER_SIZE)) +#define WMEM_CHUNK_TO_DATA(CHUNK) ((void*)((uint8_t*)(CHUNK) + WMEM_CHUNK_HEADER_SIZE)) +#define WMEM_DATA_TO_CHUNK(DATA) ((wmem_block_fast_chunk_t*)((uint8_t*)(DATA) - WMEM_CHUNK_HEADER_SIZE)) #define WMEM_BLOCK_MAX_ALLOC_SIZE (WMEM_BLOCK_SIZE - (WMEM_BLOCK_HEADER_SIZE + WMEM_CHUNK_HEADER_SIZE)) @@ -45,12 +45,12 @@ typedef struct _wmem_block_fast_hdr { struct _wmem_block_fast_hdr *next; - gint32 pos; + int32_t pos; } wmem_block_fast_hdr_t; #define WMEM_BLOCK_HEADER_SIZE WMEM_ALIGN_SIZE(sizeof(wmem_block_fast_hdr_t)) typedef struct { - guint32 len; + uint32_t len; } wmem_block_fast_chunk_t; #define WMEM_CHUNK_HEADER_SIZE WMEM_ALIGN_SIZE(sizeof(wmem_block_fast_chunk_t)) @@ -87,7 +87,7 @@ wmem_block_fast_alloc(void *private_data, const size_t size) { wmem_block_fast_allocator_t *allocator = (wmem_block_fast_allocator_t*) private_data; wmem_block_fast_chunk_t *chunk; - gint32 real_size; + int32_t real_size; if (size > WMEM_BLOCK_MAX_ALLOC_SIZE) { wmem_block_fast_jumbo_t *block; @@ -100,13 +100,13 @@ wmem_block_fast_alloc(void *private_data, const size_t size) block->prev = NULL; allocator->jumbo_list = block; - chunk = ((wmem_block_fast_chunk_t*)((guint8*)(block) + WMEM_JUMBO_HEADER_SIZE)); + chunk = ((wmem_block_fast_chunk_t*)((uint8_t*)(block) + WMEM_JUMBO_HEADER_SIZE)); chunk->len = JUMBO_MAGIC; return WMEM_CHUNK_TO_DATA(chunk); } - real_size = (gint32)(WMEM_ALIGN_SIZE(size) + WMEM_CHUNK_HEADER_SIZE); + real_size = (int32_t)(WMEM_ALIGN_SIZE(size) + WMEM_CHUNK_HEADER_SIZE); /* Allocate a new block if necessary. */ if (!allocator->block_list || @@ -114,9 +114,9 @@ wmem_block_fast_alloc(void *private_data, const size_t size) wmem_block_fast_new_block(allocator); } - chunk = (wmem_block_fast_chunk_t *) ((guint8 *) allocator->block_list + allocator->block_list->pos); + chunk = (wmem_block_fast_chunk_t *) ((uint8_t *) allocator->block_list + allocator->block_list->pos); /* safe to cast, size smaller than WMEM_BLOCK_MAX_ALLOC_SIZE */ - chunk->len = (guint32) size; + chunk->len = (uint32_t) size; allocator->block_list->pos += real_size; @@ -140,7 +140,7 @@ wmem_block_fast_realloc(void *private_data, void *ptr, const size_t size) if (chunk->len == JUMBO_MAGIC) { wmem_block_fast_jumbo_t *block; - block = ((wmem_block_fast_jumbo_t*)((guint8*)(chunk) - WMEM_JUMBO_HEADER_SIZE)); + block = ((wmem_block_fast_jumbo_t*)((uint8_t*)(chunk) - WMEM_JUMBO_HEADER_SIZE)); block = (wmem_block_fast_jumbo_t*)wmem_realloc(NULL, block, size + WMEM_JUMBO_HEADER_SIZE + WMEM_CHUNK_HEADER_SIZE); if (block->prev) { @@ -153,7 +153,7 @@ wmem_block_fast_realloc(void *private_data, void *ptr, const size_t size) if (block->next) { block->next->prev = block; } - return ((void*)((guint8*)(block) + WMEM_JUMBO_HEADER_SIZE + WMEM_CHUNK_HEADER_SIZE)); + return ((void*)((uint8_t*)(block) + WMEM_JUMBO_HEADER_SIZE + WMEM_CHUNK_HEADER_SIZE)); } else if (chunk->len < size) { /* grow */ diff --git a/wsutil/wmem/wmem_allocator_strict.c b/wsutil/wmem/wmem_allocator_strict.c index 8a84f58b8e..87ef01e297 100644 --- a/wsutil/wmem/wmem_allocator_strict.c +++ b/wsutil/wmem/wmem_allocator_strict.c @@ -36,13 +36,13 @@ typedef struct _wmem_strict_allocator_block_t { struct _wmem_strict_allocator_block_t *prev, *next; /* Just the length of real_data, not counting the canaries */ - gsize data_len; + size_t data_len; } wmem_strict_allocator_block_t; -#define WMEM_DATA_TO_BLOCK(DATA) ((wmem_strict_allocator_block_t*)((guint8*)(DATA) - WMEM_CANARY_SIZE - sizeof(wmem_strict_allocator_block_t))) -#define WMEM_BLOCK_TO_DATA(BLOCK) ((void*)((guint8*)(BLOCK) + WMEM_CANARY_SIZE + sizeof(wmem_strict_allocator_block_t))) -#define WMEM_BLOCK_TO_PRE_CANARY(BLOCK) ((guint8*)(BLOCK) + sizeof(wmem_strict_allocator_block_t)) -#define WMEM_BLOCK_TO_POST_CANARY(BLOCK) ((guint8*)(BLOCK) + WMEM_CANARY_SIZE + sizeof(wmem_strict_allocator_block_t) + (BLOCK)->data_len) +#define WMEM_DATA_TO_BLOCK(DATA) ((wmem_strict_allocator_block_t*)((uint8_t*)(DATA) - WMEM_CANARY_SIZE - sizeof(wmem_strict_allocator_block_t))) +#define WMEM_BLOCK_TO_DATA(BLOCK) ((void*)((uint8_t*)(BLOCK) + WMEM_CANARY_SIZE + sizeof(wmem_strict_allocator_block_t))) +#define WMEM_BLOCK_TO_PRE_CANARY(BLOCK) ((uint8_t*)(BLOCK) + sizeof(wmem_strict_allocator_block_t)) +#define WMEM_BLOCK_TO_POST_CANARY(BLOCK) ((uint8_t*)(BLOCK) + WMEM_CANARY_SIZE + sizeof(wmem_strict_allocator_block_t) + (BLOCK)->data_len) #define WMEM_FULL_SIZE(SIZE) ((SIZE) + sizeof(wmem_strict_allocator_block_t) + (2*WMEM_CANARY_SIZE)) typedef struct _wmem_strict_allocator_t { @@ -55,8 +55,8 @@ typedef struct _wmem_strict_allocator_t { static inline void wmem_strict_block_check_canaries(wmem_strict_allocator_block_t *block) { - guint i; - guint8 *canary; + unsigned i; + uint8_t *canary; canary = WMEM_BLOCK_TO_PRE_CANARY(block); for (i=0; i<WMEM_CANARY_SIZE; i++) g_assert_true(canary[i] == WMEM_CANARY_VALUE); @@ -73,8 +73,8 @@ wmem_strict_alloc(void *private_data, const size_t size) { wmem_strict_allocator_t *allocator; wmem_strict_allocator_block_t *block; - guint i; - guint8 *canary; + unsigned i; + uint8_t *canary; allocator = (wmem_strict_allocator_t*) private_data; diff --git a/wsutil/wmem/wmem_array.c b/wsutil/wmem/wmem_array.c index b8e3714eb7..47f6e8e035 100644 --- a/wsutil/wmem/wmem_array.c +++ b/wsutil/wmem/wmem_array.c @@ -27,19 +27,19 @@ struct _wmem_array_t { wmem_allocator_t *allocator; - guint8 *buf; + uint8_t *buf; - gsize elem_size; + size_t elem_size; - guint elem_count; - guint alloc_count; + unsigned elem_count; + unsigned alloc_count; - gboolean null_terminated; + bool null_terminated; }; wmem_array_t * -wmem_array_sized_new(wmem_allocator_t *allocator, gsize elem_size, - guint alloc_count) +wmem_array_sized_new(wmem_allocator_t *allocator, size_t elem_size, + unsigned alloc_count) { wmem_array_t *array; @@ -49,16 +49,16 @@ wmem_array_sized_new(wmem_allocator_t *allocator, gsize elem_size, array->elem_size = elem_size; array->elem_count = 0; array->alloc_count = alloc_count ? alloc_count : 1; - array->null_terminated = FALSE; + array->null_terminated = false; - array->buf = (guint8 *)wmem_alloc(array->allocator, + array->buf = (uint8_t *)wmem_alloc(array->allocator, array->elem_size * array->alloc_count); return array; } wmem_array_t * -wmem_array_new(wmem_allocator_t *allocator, const gsize elem_size) +wmem_array_new(wmem_allocator_t *allocator, const size_t elem_size) { wmem_array_t *array; @@ -68,9 +68,9 @@ wmem_array_new(wmem_allocator_t *allocator, const gsize elem_size) } void -wmem_array_grow(wmem_array_t *array, const guint to_add) +wmem_array_grow(wmem_array_t *array, const unsigned to_add) { - guint new_alloc_count, new_count; + unsigned new_alloc_count, new_count; new_alloc_count = array->alloc_count; new_count = array->elem_count + to_add; @@ -83,7 +83,7 @@ wmem_array_grow(wmem_array_t *array, const guint to_add) return; } - array->buf = (guint8 *)wmem_realloc(array->allocator, array->buf, + array->buf = (uint8_t *)wmem_realloc(array->allocator, array->buf, new_alloc_count * array->elem_size); array->alloc_count = new_alloc_count; @@ -101,7 +101,7 @@ wmem_array_write_null_terminator(wmem_array_t *array) void wmem_array_set_null_terminator(wmem_array_t *array) { - array->null_terminated = TRUE; + array->null_terminated = true; wmem_array_write_null_terminator(array); } @@ -112,7 +112,7 @@ wmem_array_bzero(wmem_array_t *array) } void -wmem_array_append(wmem_array_t *array, const void *in, guint count) +wmem_array_append(wmem_array_t *array, const void *in, unsigned count) { wmem_array_grow(array, count); @@ -125,14 +125,14 @@ wmem_array_append(wmem_array_t *array, const void *in, guint count) } void * -wmem_array_index(wmem_array_t *array, guint array_index) +wmem_array_index(wmem_array_t *array, unsigned array_index) { g_assert(array_index < array->elem_count); return &array->buf[array_index * array->elem_size]; } int -wmem_array_try_index(wmem_array_t *array, guint array_index, void *val) +wmem_array_try_index(wmem_array_t *array, unsigned array_index, void *val) { if (array_index >= array->elem_count) return -1; @@ -152,7 +152,7 @@ wmem_array_get_raw(wmem_array_t *array) return array->buf; } -guint +unsigned wmem_array_get_count(wmem_array_t *array) { if (array == NULL) diff --git a/wsutil/wmem/wmem_array.h b/wsutil/wmem/wmem_array.h index a7c157ebbb..e813232da9 100644 --- a/wsutil/wmem/wmem_array.h +++ b/wsutil/wmem/wmem_array.h @@ -36,18 +36,18 @@ typedef struct _wmem_array_t wmem_array_t; WS_DLL_PUBLIC wmem_array_t * -wmem_array_sized_new(wmem_allocator_t *allocator, gsize elem_size, - guint alloc_count) +wmem_array_sized_new(wmem_allocator_t *allocator, size_t elem_size, + unsigned alloc_count) G_GNUC_MALLOC; WS_DLL_PUBLIC wmem_array_t * -wmem_array_new(wmem_allocator_t *allocator, const gsize elem_size) +wmem_array_new(wmem_allocator_t *allocator, const size_t elem_size) G_GNUC_MALLOC; WS_DLL_PUBLIC void -wmem_array_grow(wmem_array_t *array, const guint to_add); +wmem_array_grow(wmem_array_t *array, const unsigned to_add); WS_DLL_PUBLIC void @@ -59,18 +59,18 @@ wmem_array_bzero(wmem_array_t *array); WS_DLL_PUBLIC void -wmem_array_append(wmem_array_t *array, const void *in, guint count); +wmem_array_append(wmem_array_t *array, const void *in, unsigned count); #define wmem_array_append_one(ARRAY, VAL) \ wmem_array_append((ARRAY), &(VAL), 1) WS_DLL_PUBLIC void * -wmem_array_index(wmem_array_t *array, guint array_index); +wmem_array_index(wmem_array_t *array, unsigned array_index); WS_DLL_PUBLIC int -wmem_array_try_index(wmem_array_t *array, guint array_index, void *val); +wmem_array_try_index(wmem_array_t *array, unsigned array_index, void *val); WS_DLL_PUBLIC void @@ -81,7 +81,7 @@ void * wmem_array_get_raw(wmem_array_t *array); WS_DLL_PUBLIC -guint +unsigned wmem_array_get_count(wmem_array_t *array); /* Truncates the underlying array to the elements contained within diff --git a/wsutil/wmem/wmem_core.c b/wsutil/wmem/wmem_core.c index d7f03203d6..a166bf8400 100644 --- a/wsutil/wmem/wmem_core.c +++ b/wsutil/wmem/wmem_core.c @@ -25,7 +25,7 @@ /* Set according to the WIRESHARK_DEBUG_WMEM_OVERRIDE environment variable in * wmem_init. Should not be set again. */ -static gboolean do_override = FALSE; +static bool do_override = false; static wmem_allocator_type_t override_type; void * @@ -97,7 +97,7 @@ wmem_realloc(wmem_allocator_t *allocator, void *ptr, const size_t size) } static void -wmem_free_all_real(wmem_allocator_t *allocator, gboolean final) +wmem_free_all_real(wmem_allocator_t *allocator, bool final) { wmem_call_callbacks(allocator, final ? WMEM_CB_DESTROY_EVENT : WMEM_CB_FREE_EVENT); @@ -107,7 +107,7 @@ wmem_free_all_real(wmem_allocator_t *allocator, gboolean final) void wmem_free_all(wmem_allocator_t *allocator) { - wmem_free_all_real(allocator, FALSE); + wmem_free_all_real(allocator, false); } void @@ -120,7 +120,7 @@ void wmem_destroy_allocator(wmem_allocator_t *allocator) { - wmem_free_all_real(allocator, TRUE); + wmem_free_all_real(allocator, true); allocator->cleanup(allocator->private_data); wmem_free(NULL, allocator); } @@ -141,7 +141,7 @@ wmem_allocator_new(const wmem_allocator_type_t type) allocator = wmem_new(NULL, wmem_allocator_t); allocator->type = real_type; allocator->callbacks = NULL; - allocator->in_scope = TRUE; + allocator->in_scope = true; switch (real_type) { case WMEM_ALLOCATOR_SIMPLE: @@ -176,10 +176,10 @@ wmem_init(void) override_env = getenv("WIRESHARK_DEBUG_WMEM_OVERRIDE"); if (override_env == NULL) { - do_override = FALSE; + do_override = false; } else { - do_override = TRUE; + do_override = true; if (strncmp(override_env, "simple", strlen("simple")) == 0) { override_type = WMEM_ALLOCATOR_SIMPLE; } @@ -194,7 +194,7 @@ wmem_init(void) } else { g_warning("Unrecognized wmem override"); - do_override = FALSE; + do_override = false; } } @@ -209,17 +209,17 @@ wmem_cleanup(void) void wmem_enter_scope(wmem_allocator_t *allocator) { - allocator->in_scope = TRUE; + allocator->in_scope = true; } void wmem_leave_scope(wmem_allocator_t *allocator) { wmem_free_all(allocator); - allocator->in_scope = FALSE; + allocator->in_scope = false; } -gboolean +bool wmem_in_scope(wmem_allocator_t *allocator) { return allocator->in_scope; diff --git a/wsutil/wmem/wmem_core.h b/wsutil/wmem/wmem_core.h index 170bd9abad..2f42313339 100644 --- a/wsutil/wmem/wmem_core.h +++ b/wsutil/wmem/wmem_core.h @@ -90,7 +90,7 @@ G_GNUC_MALLOC; * if the number of elements is negative), and the product otherwise. */ #define wmem_safe_mult_type_size(type, num) \ - ((((num) <= 0) || ((gsize)sizeof(type) > (G_MAXSSIZE / (gsize)(num)))) ? 0 : (sizeof(type) * (num))) + ((((num) <= 0) || ((size_t)sizeof(type) > (G_MAXSSIZE / (size_t)(num)))) ? 0 : (sizeof(type) * (num))) /** Allocate memory sufficient to hold n objects of the given type. * @@ -227,7 +227,7 @@ void wmem_leave_scope(wmem_allocator_t *allocator); WS_DLL_PUBLIC -gboolean +bool wmem_in_scope(wmem_allocator_t *allocator); /** @} */ diff --git a/wsutil/wmem/wmem_interval_tree.c b/wsutil/wmem/wmem_interval_tree.c index e68c7396dc..8b28549ac8 100644 --- a/wsutil/wmem/wmem_interval_tree.c +++ b/wsutil/wmem/wmem_interval_tree.c @@ -47,7 +47,7 @@ update_max_edge(wmem_tree_node_t *node) wmem_range_t *range; const wmem_range_t *range_l; const wmem_range_t *range_r; - guint64 maxEdge = 0; + uint64_t maxEdge = 0; if(!node) { return ; @@ -74,7 +74,7 @@ update_max_edge(wmem_tree_node_t *node) } } -gboolean +bool wmem_itree_range_overlap(const wmem_range_t *r1, const wmem_range_t *r2) { return (r1->low <= r2->high && r2->low <= r1->high); @@ -96,7 +96,7 @@ wmem_itree_new(wmem_allocator_t *allocator) return tree; } -gboolean +bool wmem_itree_is_empty(wmem_itree_t *tree) { return wmem_tree_is_empty(tree); @@ -118,7 +118,7 @@ wmem_tree_compare_ranges(const wmem_range_t *ra, const wmem_range_t *rb) void -wmem_itree_insert(wmem_itree_t *tree, const guint64 low, const guint64 high, void *data) +wmem_itree_insert(wmem_itree_t *tree, const uint64_t low, const uint64_t high, void *data) { wmem_tree_node_t *node; wmem_range_t *range = (wmem_range_t *)wmem_new(tree->data_allocator, wmem_range_t); @@ -159,7 +159,7 @@ wmem_itree_find_intervals_in_subtree(wmem_tree_node_t *node, wmem_range_t reques } wmem_list_t * -wmem_itree_find_intervals(wmem_itree_t *tree, wmem_allocator_t *allocator, guint64 low, guint64 high) +wmem_itree_find_intervals(wmem_itree_t *tree, wmem_allocator_t *allocator, uint64_t low, uint64_t high) { wmem_list_t *results = NULL; wmem_range_t requested = { low, high, 0 }; diff --git a/wsutil/wmem/wmem_interval_tree.h b/wsutil/wmem/wmem_interval_tree.h index 128455faf1..1d7bc4df90 100644 --- a/wsutil/wmem/wmem_interval_tree.h +++ b/wsutil/wmem/wmem_interval_tree.h @@ -37,9 +37,9 @@ struct _wmem_tree_t; typedef struct _wmem_tree_t wmem_itree_t; struct _wmem_range_t { - guint64 low; /* low is used as the key in the binary tree */ - guint64 high; /* Max value of the range */ - guint64 max_edge; /* max value among subtrees */ + uint64_t low; /* low is used as the key in the binary tree */ + uint64_t high; /* Max value of the range */ + uint64_t max_edge; /* max value among subtrees */ }; WS_DLL_PUBLIC @@ -50,7 +50,7 @@ G_GNUC_MALLOC; /** Returns true if the tree is empty (has no nodes). */ WS_DLL_PUBLIC -gboolean +bool wmem_itree_is_empty(wmem_itree_t *tree); @@ -60,7 +60,7 @@ wmem_itree_is_empty(wmem_itree_t *tree); */ WS_DLL_PUBLIC void -wmem_itree_insert(wmem_itree_t *tree, const guint64 low, const guint64 high, void *data); +wmem_itree_insert(wmem_itree_t *tree, const uint64_t low, const uint64_t high, void *data); /* @@ -69,7 +69,7 @@ wmem_itree_insert(wmem_itree_t *tree, const guint64 low, const guint64 high, voi */ WS_DLL_PUBLIC wmem_list_t * -wmem_itree_find_intervals(wmem_itree_t *tree, wmem_allocator_t *allocator, guint64 low, guint64 high); +wmem_itree_find_intervals(wmem_itree_t *tree, wmem_allocator_t *allocator, uint64_t low, uint64_t high); /** diff --git a/wsutil/wmem/wmem_list.c b/wsutil/wmem/wmem_list.c index b54881b93c..c4c8aacbcb 100644 --- a/wsutil/wmem/wmem_list.c +++ b/wsutil/wmem/wmem_list.c @@ -21,12 +21,12 @@ struct _wmem_list_frame_t { }; struct _wmem_list_t { - guint count; + unsigned count; wmem_list_frame_t *head, *tail; wmem_allocator_t *allocator; }; -guint +unsigned wmem_list_count(const wmem_list_t *list) { return list->count; @@ -248,7 +248,7 @@ wmem_destroy_list(wmem_list_t *list) } void -wmem_list_foreach(wmem_list_t *list, GFunc foreach_func, gpointer user_data) +wmem_list_foreach(wmem_list_t *list, GFunc foreach_func, void * user_data) { wmem_list_frame_t *cur; diff --git a/wsutil/wmem/wmem_list.h b/wsutil/wmem/wmem_list.h index edfc018417..fc0e52291d 100644 --- a/wsutil/wmem/wmem_list.h +++ b/wsutil/wmem/wmem_list.h @@ -37,7 +37,7 @@ typedef struct _wmem_list_t wmem_list_t; typedef struct _wmem_list_frame_t wmem_list_frame_t; WS_DLL_PUBLIC -guint +unsigned wmem_list_count(const wmem_list_t *list); WS_DLL_PUBLIC @@ -99,7 +99,7 @@ G_GNUC_MALLOC; WS_DLL_PUBLIC void -wmem_list_foreach(wmem_list_t *list, GFunc foreach_func, gpointer user_data); +wmem_list_foreach(wmem_list_t *list, GFunc foreach_func, void * user_data); WS_DLL_PUBLIC void diff --git a/wsutil/wmem/wmem_map.c b/wsutil/wmem/wmem_map.c index 2807e06aa9..ea76f4555c 100644 --- a/wsutil/wmem/wmem_map.c +++ b/wsutil/wmem/wmem_map.c @@ -18,11 +18,11 @@ #include "wmem_map_int.h" #include "wmem_user_cb.h" -static guint32 x; /* Used for universal integer hashing (see the HASH macro) */ +static uint32_t x; /* Used for universal integer hashing (see the HASH macro) */ /* Used for the wmem_strong_hash() function */ -static guint32 preseed; -static guint32 postseed; +static uint32_t preseed; +static uint32_t postseed; void wmem_init_hashing(void) @@ -42,7 +42,7 @@ typedef struct _wmem_map_item_t { } wmem_map_item_t; struct _wmem_map_t { - guint count; /* number of items stored */ + unsigned count; /* number of items stored */ /* The base-2 logarithm of the actual size of the table. We store this * value for efficiency in hashing, since finding the actual capacity @@ -55,8 +55,8 @@ struct _wmem_map_t { GHashFunc hash_func; GEqualFunc eql_func; - guint metadata_scope_cb_id; - guint data_scope_cb_id; + unsigned metadata_scope_cb_id; + unsigned data_scope_cb_id; wmem_allocator_t *metadata_allocator; wmem_allocator_t *data_allocator; @@ -74,7 +74,7 @@ struct _wmem_map_t { * https://en.wikipedia.org/wiki/Universal_hashing#Avoiding_modular_arithmetic */ #define HASH(MAP, KEY) \ - ((guint32)(((MAP)->hash_func(KEY) * x) >> (32 - (MAP)->capacity))) + ((uint32_t)(((MAP)->hash_func(KEY) * x) >> (32 - (MAP)->capacity))) static void wmem_map_init_table(wmem_map_t *map) @@ -102,7 +102,7 @@ wmem_map_new(wmem_allocator_t *allocator, return map; } -static gboolean +static bool wmem_map_reset_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event, void *user_data) { @@ -116,10 +116,10 @@ wmem_map_reset_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event, wmem_free(map->metadata_allocator, map); } - return TRUE; + return true; } -static gboolean +static bool wmem_map_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { @@ -127,7 +127,7 @@ wmem_map_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, wmem_unregister_callback(map->data_allocator, map->data_scope_cb_id); - return FALSE; + return false; } wmem_map_t * @@ -156,7 +156,7 @@ wmem_map_grow(wmem_map_t *map) { wmem_map_item_t **old_table, *cur, *nxt; size_t old_cap, i; - guint slot; + unsigned slot; /* store the old table and capacity */ old_table = map->table; @@ -226,14 +226,14 @@ wmem_map_insert(wmem_map_t *map, const void *key, void *value) return NULL; } -gboolean +bool wmem_map_contains(wmem_map_t *map, const void *key) { wmem_map_item_t *item; /* Make sure we have a table */ if (map->table == NULL) { - return FALSE; + return false; } /* find correct slot */ @@ -242,12 +242,12 @@ wmem_map_contains(wmem_map_t *map, const void *key) /* scan list of items in this slot for the correct value */ while (item) { if (map->eql_func(key, item->key)) { - return TRUE; + return true; } item = item->next; } - return FALSE; + return false; } void * @@ -274,14 +274,14 @@ wmem_map_lookup(wmem_map_t *map, const void *key) return NULL; } -gboolean +bool wmem_map_lookup_extended(wmem_map_t *map, const void *key, const void **orig_key, void **value) { wmem_map_item_t *item; /* Make sure we have a table */ if (map->table == NULL) { - return FALSE; + return false; } /* find correct slot */ @@ -296,12 +296,12 @@ wmem_map_lookup_extended(wmem_map_t *map, const void *key, const void **orig_key if (value) { *value = item->value; } - return TRUE; + return true; } item = item->next; } - return FALSE; + return false; } void * @@ -336,14 +336,14 @@ wmem_map_remove(wmem_map_t *map, const void *key) return NULL; } -gboolean +bool wmem_map_steal(wmem_map_t *map, const void *key) { wmem_map_item_t **item, *tmp; /* Make sure we have a table */ if (map->table == NULL) { - return FALSE; + return false; } /* get a pointer to the slot */ @@ -356,13 +356,13 @@ wmem_map_steal(wmem_map_t *map, const void *key) tmp = (*item); (*item) = tmp->next; map->count--; - return TRUE; + return true; } item = &((*item)->next); } /* didn't find it */ - return FALSE; + return false; } wmem_list_t* @@ -389,7 +389,7 @@ wmem_map_get_keys(wmem_allocator_t *list_allocator, wmem_map_t *map) } void -wmem_map_foreach(wmem_map_t *map, GHFunc foreach_func, gpointer user_data) +wmem_map_foreach(wmem_map_t *map, GHFunc foreach_func, void * user_data) { wmem_map_item_t *cur; unsigned i; @@ -402,14 +402,14 @@ wmem_map_foreach(wmem_map_t *map, GHFunc foreach_func, gpointer user_data) for (i = 0; i < CAPACITY(map); i++) { cur = map->table[i]; while (cur) { - foreach_func((gpointer)cur->key, (gpointer)cur->value, user_data); + foreach_func((void *)cur->key, (void *)cur->value, user_data); cur = cur->next; } } } -guint -wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, gpointer user_data) +unsigned +wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, void * user_data) { wmem_map_item_t **item, *tmp; unsigned i, deleted = 0; @@ -422,7 +422,7 @@ wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, gpointer user_dat for (i = 0; i < CAPACITY(map); i++) { item = &(map->table[i]); while (*item) { - if (foreach_func((gpointer)(*item)->key, (gpointer)(*item)->value, user_data)) { + if (foreach_func((void *)(*item)->key, (void *)(*item)->value, user_data)) { tmp = *item; *item = tmp->next; wmem_free(map->data_allocator, tmp); @@ -436,7 +436,7 @@ wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, gpointer user_dat return deleted; } -guint +unsigned wmem_map_size(wmem_map_t *map) { return map->count; @@ -447,11 +447,11 @@ wmem_map_size(wmem_map_t *map) * generally secure against collision attacks. See * http://blog.booking.com/hardening-perls-hash-function.html */ -guint32 -wmem_strong_hash(const guint8 *buf, const size_t len) +uint32_t +wmem_strong_hash(const uint8_t *buf, const size_t len) { - const guint8 * const end = (const guint8 *)buf + len; - guint32 hash = preseed + (guint32)len; + const uint8_t * const end = (const uint8_t *)buf + len; + uint32_t hash = preseed + (uint32_t)len; while (buf < end) { hash += (hash << 10); @@ -461,19 +461,19 @@ wmem_strong_hash(const guint8 *buf, const size_t len) hash += (hash << 10); hash ^= (hash >> 6); - hash += ((guint8*)&postseed)[0]; + hash += ((uint8_t*)&postseed)[0]; hash += (hash << 10); hash ^= (hash >> 6); - hash += ((guint8*)&postseed)[1]; + hash += ((uint8_t*)&postseed)[1]; hash += (hash << 10); hash ^= (hash >> 6); - hash += ((guint8*)&postseed)[2]; + hash += ((uint8_t*)&postseed)[2]; hash += (hash << 10); hash ^= (hash >> 6); - hash += ((guint8*)&postseed)[3]; + hash += ((uint8_t*)&postseed)[3]; hash += (hash << 10); hash ^= (hash >> 6); @@ -483,22 +483,22 @@ wmem_strong_hash(const guint8 *buf, const size_t len) return (hash + (hash << 15)); } -guint +unsigned wmem_str_hash(gconstpointer key) { - return wmem_strong_hash((const guint8 *)key, strlen((const char *)key)); + return wmem_strong_hash((const uint8_t *)key, strlen((const char *)key)); } -guint +unsigned wmem_int64_hash(gconstpointer key) { - return wmem_strong_hash((const guint8 *)key, sizeof(guint64)); + return wmem_strong_hash((const uint8_t *)key, sizeof(uint64_t)); } -guint +unsigned wmem_double_hash(gconstpointer key) { - return wmem_strong_hash((const guint8 *)key, sizeof(double)); + return wmem_strong_hash((const uint8_t *)key, sizeof(double)); } /* diff --git a/wsutil/wmem/wmem_map.h b/wsutil/wmem/wmem_map.h index 53dacb2859..96b35a24c9 100644 --- a/wsutil/wmem/wmem_map.h +++ b/wsutil/wmem/wmem_map.h @@ -94,7 +94,7 @@ wmem_map_insert(wmem_map_t *map, const void *key, void *value); * @return true if the key is in the map, otherwise false. */ WS_DLL_PUBLIC -gboolean +bool wmem_map_contains(wmem_map_t *map, const void *key); /** Lookup a value in the map. @@ -117,7 +117,7 @@ wmem_map_lookup(wmem_map_t *map, const void *key); * @return true if the key is in the map, otherwise false. */ WS_DLL_PUBLIC -gboolean +bool wmem_map_lookup_extended(wmem_map_t *map, const void *key, const void **orig_key, void **value); /** Remove a value from the map. If no value is stored at that key, nothing @@ -136,10 +136,10 @@ wmem_map_remove(wmem_map_t *map, const void *key); * * @param map The map to remove from. * @param key The key of the value to remove. - * @return TRUE if key is found FALSE if not. + * @return true if key is found false if not. */ WS_DLL_PUBLIC -gboolean +bool wmem_map_steal(wmem_map_t *map, const void *key); /** Retrieves a list of keys inside the map @@ -162,10 +162,10 @@ wmem_map_get_keys(wmem_allocator_t *list_allocator, wmem_map_t *map); */ WS_DLL_PUBLIC void -wmem_map_foreach(wmem_map_t *map, GHFunc foreach_func, gpointer user_data); +wmem_map_foreach(wmem_map_t *map, GHFunc foreach_func, void * user_data); /** Run a function against all key/value pairs in the map. If the - * function returns TRUE, then the key/value pair is removed from + * function returns true, then the key/value pair is removed from * the map. The order of the calls is unpredictable, since it is * based on the internal storage of data. * @@ -175,8 +175,8 @@ wmem_map_foreach(wmem_map_t *map, GHFunc foreach_func, gpointer user_data); * @return The number of items removed */ WS_DLL_PUBLIC -guint -wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, gpointer user_data); +unsigned +wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, void * user_data); /** Return the number of elements of the map. * @@ -184,7 +184,7 @@ wmem_map_foreach_remove(wmem_map_t *map, GHRFunc foreach_func, gpointer user_dat * @return the number of elements */ WS_DLL_PUBLIC -guint +unsigned wmem_map_size(wmem_map_t *map); /** Compute a strong hash value for an arbitrary sequence of bytes. Use of this @@ -198,28 +198,28 @@ wmem_map_size(wmem_map_t *map); * @return The hash value. */ WS_DLL_PUBLIC -guint32 -wmem_strong_hash(const guint8 *buf, const size_t len); +uint32_t +wmem_strong_hash(const uint8_t *buf, const size_t len); /** An implementation of GHashFunc using wmem_strong_hash. Prefer this over * g_str_hash when the data comes from an untrusted source. */ WS_DLL_PUBLIC -guint +unsigned wmem_str_hash(gconstpointer key); /** An implementation of GHashFunc using wmem_strong_hash. Prefer this over * g_int64_hash when the data comes from an untrusted source. */ WS_DLL_PUBLIC -guint +unsigned wmem_int64_hash(gconstpointer key); /** An implementation of GHashFunc using wmem_strong_hash. Prefer this over * g_double_hash when the data comes from an untrusted source. */ WS_DLL_PUBLIC -guint +unsigned wmem_double_hash(gconstpointer key); /** @} diff --git a/wsutil/wmem/wmem_miscutl.c b/wsutil/wmem/wmem_miscutl.c index 904a7ed79d..1442644731 100644 --- a/wsutil/wmem/wmem_miscutl.c +++ b/wsutil/wmem/wmem_miscutl.c @@ -29,13 +29,13 @@ wmem_memdup(wmem_allocator_t *allocator, const void *source, const size_t size) return dest; } -gint +int wmem_compare_int(gconstpointer a, gconstpointer b) { return GPOINTER_TO_INT(a) - GPOINTER_TO_INT(b); } -gint +int wmem_compare_uint(gconstpointer a, gconstpointer b) { return GPOINTER_TO_UINT(a) > GPOINTER_TO_UINT(b) ? 1 : (GPOINTER_TO_UINT(a) < GPOINTER_TO_UINT(b) ? -1 : 0); diff --git a/wsutil/wmem/wmem_miscutl.h b/wsutil/wmem/wmem_miscutl.h index 125f49379f..714ee5ccdf 100644 --- a/wsutil/wmem/wmem_miscutl.h +++ b/wsutil/wmem/wmem_miscutl.h @@ -43,11 +43,11 @@ G_GNUC_MALLOC; /** Generic GCompareFunc implementations to compare signed/unsigned integer */ WS_DLL_PUBLIC -gint +int wmem_compare_int(gconstpointer a, gconstpointer b); WS_DLL_PUBLIC -gint +int wmem_compare_uint(gconstpointer a, gconstpointer b); /** @} diff --git a/wsutil/wmem/wmem_multimap.c b/wsutil/wmem/wmem_multimap.c index f97d0c1126..b36e5ced5f 100644 --- a/wsutil/wmem/wmem_multimap.c +++ b/wsutil/wmem/wmem_multimap.c @@ -24,8 +24,8 @@ struct _wmem_multimap_t { wmem_map_t *map; - guint metadata_scope_cb_id; - guint data_scope_cb_id; + unsigned metadata_scope_cb_id; + unsigned data_scope_cb_id; wmem_allocator_t *metadata_allocator; wmem_allocator_t *data_allocator; @@ -46,7 +46,7 @@ wmem_multimap_new(wmem_allocator_t *allocator, return multimap; } -static gboolean +static bool wmem_multimap_reset_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event, void *user_data) { @@ -57,10 +57,10 @@ wmem_multimap_reset_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event, wmem_free(multimap->metadata_allocator, multimap); } - return TRUE; + return true; } -static gboolean +static bool wmem_multimap_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { @@ -68,7 +68,7 @@ wmem_multimap_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event wmem_unregister_callback(multimap->data_allocator, multimap->data_scope_cb_id); - return FALSE; + return false; } wmem_multimap_t * @@ -96,22 +96,22 @@ wmem_multimap_get_keys(wmem_allocator_t *list_allocator, wmem_multimap_t *map) } static void -count_nodes(gpointer key _U_, gpointer value, gpointer user_data) +count_nodes(void * key _U_, void * value, void * user_data) { - guint* count = (guint*)user_data; + unsigned* count = (unsigned*)user_data; (*count) += wmem_tree_count(value); } -guint +unsigned wmem_multimap_size(wmem_multimap_t *map) { - guint count = 0; + unsigned count = 0; wmem_map_foreach(map->map, count_nodes, &count); return count; } -guint +unsigned wmem_multimap_count(wmem_multimap_t *map, const void *key) { wmem_tree_t *tree; @@ -122,16 +122,16 @@ wmem_multimap_count(wmem_multimap_t *map, const void *key) return wmem_tree_count(tree); } -gboolean -wmem_multimap_insert32(wmem_multimap_t *map, const void *key, guint32 frame_num, void *value) +bool +wmem_multimap_insert32(wmem_multimap_t *map, const void *key, uint32_t frame_num, void *value) { wmem_tree_t *tree; - gboolean ret = TRUE; + bool ret = true; if ((tree = wmem_map_lookup(map->map, key)) == NULL) { tree = wmem_tree_new(map->data_allocator); wmem_map_insert(map->map, key, tree); - ret = FALSE; + ret = false; } wmem_tree_insert32(tree, frame_num, value); @@ -139,7 +139,7 @@ wmem_multimap_insert32(wmem_multimap_t *map, const void *key, guint32 frame_num, } void * -wmem_multimap_lookup32(wmem_multimap_t *map, const void *key, guint32 frame_num) +wmem_multimap_lookup32(wmem_multimap_t *map, const void *key, uint32_t frame_num) { wmem_tree_t *tree; @@ -150,7 +150,7 @@ wmem_multimap_lookup32(wmem_multimap_t *map, const void *key, guint32 frame_num) } void * -wmem_multimap_lookup32_le(wmem_multimap_t *map, const void *key, guint32 frame_num) +wmem_multimap_lookup32_le(wmem_multimap_t *map, const void *key, uint32_t frame_num) { wmem_tree_t *tree; @@ -161,7 +161,7 @@ wmem_multimap_lookup32_le(wmem_multimap_t *map, const void *key, guint32 frame_n } void * -wmem_multimap_remove32(wmem_multimap_t *map, const void *key, const guint32 frame_num) +wmem_multimap_remove32(wmem_multimap_t *map, const void *key, const uint32_t frame_num) { wmem_tree_t *tree; diff --git a/wsutil/wmem/wmem_multimap.h b/wsutil/wmem/wmem_multimap.h index 300eb0fabf..06170aebf9 100644 --- a/wsutil/wmem/wmem_multimap.h +++ b/wsutil/wmem/wmem_multimap.h @@ -97,7 +97,7 @@ wmem_multimap_get_keys(wmem_allocator_t *list_allocator, wmem_multimap_t *map); * @return the number of elements */ WS_DLL_PUBLIC -guint +unsigned wmem_multimap_size(wmem_multimap_t *map); /** Returns the number of values in the multimap with a certain hash key. @@ -111,7 +111,7 @@ wmem_multimap_size(wmem_multimap_t *map); * tree exists at that key. */ WS_DLL_PUBLIC -guint +unsigned wmem_multimap_count(wmem_multimap_t *map, const void *key); /** Insert a value in the multimap. @@ -120,7 +120,7 @@ wmem_multimap_count(wmem_multimap_t *map, const void *key); * @param key The key to insert by in the map. * @param frame_num The key to insert by in the tree. * @param value The value to insert. - * @return TRUE if there was already a tree mapped at key, in which case the + * @return true if there was already a tree mapped at key, in which case the * caller may safely free key. (This is not necessary if key is allocated with * a wmem pool.) * @@ -130,8 +130,8 @@ wmem_multimap_count(wmem_multimap_t *map, const void *key); * then you must ensure that the pair is unique or do a lookup before inserting. */ WS_DLL_PUBLIC -gboolean -wmem_multimap_insert32(wmem_multimap_t *map, const void *key, guint32 frame_num, void *value); +bool +wmem_multimap_insert32(wmem_multimap_t *map, const void *key, uint32_t frame_num, void *value); /** Lookup a value in the multimap combination with an exact match. * @@ -142,7 +142,7 @@ wmem_multimap_insert32(wmem_multimap_t *map, const void *key, guint32 frame_num, */ WS_DLL_PUBLIC void * -wmem_multimap_lookup32(wmem_multimap_t *map, const void *key, const guint32 frame_num); +wmem_multimap_lookup32(wmem_multimap_t *map, const void *key, const uint32_t frame_num); /** Lookup a value in the multimap with an exact match for the map key * and the largest value less than or equal to the tree key. This is @@ -156,7 +156,7 @@ wmem_multimap_lookup32(wmem_multimap_t *map, const void *key, const guint32 fram */ WS_DLL_PUBLIC void * -wmem_multimap_lookup32_le(wmem_multimap_t *map, const void *key, const guint32 frame_num); +wmem_multimap_lookup32_le(wmem_multimap_t *map, const void *key, const uint32_t frame_num); /** Remove a value from the multimap. If no value is stored at that key pair, * nothing happens. As with wmem_tree, this is not really a remove, but the @@ -169,7 +169,7 @@ wmem_multimap_lookup32_le(wmem_multimap_t *map, const void *key, const guint32 f */ WS_DLL_PUBLIC void * -wmem_multimap_remove32(wmem_multimap_t *map, const void *key, const guint32 frame_num); +wmem_multimap_remove32(wmem_multimap_t *map, const void *key, const uint32_t frame_num); /** @} * @} */ diff --git a/wsutil/wmem/wmem_strbuf.c b/wsutil/wmem/wmem_strbuf.c index 11c9548d67..ff49f6b8ba 100644 --- a/wsutil/wmem/wmem_strbuf.c +++ b/wsutil/wmem/wmem_strbuf.c @@ -39,14 +39,14 @@ wmem_strbuf_new_sized(wmem_allocator_t *allocator, strbuf->len = 0; strbuf->alloc_size = alloc_size ? alloc_size : DEFAULT_MINIMUM_SIZE; - strbuf->str = (gchar *)wmem_alloc(strbuf->allocator, strbuf->alloc_size); + strbuf->str = (char *)wmem_alloc(strbuf->allocator, strbuf->alloc_size); strbuf->str[0] = '\0'; return strbuf; } wmem_strbuf_t * -wmem_strbuf_new_len(wmem_allocator_t *allocator, const gchar *str, size_t len) +wmem_strbuf_new_len(wmem_allocator_t *allocator, const char *str, size_t len) { wmem_strbuf_t *strbuf; size_t alloc_size; @@ -71,7 +71,7 @@ wmem_strbuf_new_len(wmem_allocator_t *allocator, const gchar *str, size_t len) } wmem_strbuf_t * -wmem_strbuf_new(wmem_allocator_t *allocator, const gchar *str) +wmem_strbuf_new(wmem_allocator_t *allocator, const char *str) { return wmem_strbuf_new_len(allocator, str, str ? strlen(str) : 0); } @@ -115,13 +115,13 @@ wmem_strbuf_grow(wmem_strbuf_t *strbuf, const size_t to_add) return; } - strbuf->str = (gchar *)wmem_realloc(strbuf->allocator, strbuf->str, new_alloc_len); + strbuf->str = (char *)wmem_realloc(strbuf->allocator, strbuf->str, new_alloc_len); strbuf->alloc_size = new_alloc_len; } void -wmem_strbuf_append(wmem_strbuf_t *strbuf, const gchar *str) +wmem_strbuf_append(wmem_strbuf_t *strbuf, const char *str) { size_t append_len; @@ -139,7 +139,7 @@ wmem_strbuf_append(wmem_strbuf_t *strbuf, const gchar *str) } void -wmem_strbuf_append_len(wmem_strbuf_t *strbuf, const gchar *str, size_t append_len) +wmem_strbuf_append_len(wmem_strbuf_t *strbuf, const char *str, size_t append_len) { if (!append_len || !str) { @@ -180,7 +180,7 @@ int _strbuf_vsnprintf(wmem_strbuf_t *strbuf, const char *format, va_list ap) } void -wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const gchar *fmt, va_list ap) +wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const char *fmt, va_list ap) { int want_len; va_list ap2; @@ -200,7 +200,7 @@ wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const gchar *fmt, va_list ap) } void -wmem_strbuf_append_printf(wmem_strbuf_t *strbuf, const gchar *format, ...) +wmem_strbuf_append_printf(wmem_strbuf_t *strbuf, const char *format, ...) { va_list ap; @@ -210,7 +210,7 @@ wmem_strbuf_append_printf(wmem_strbuf_t *strbuf, const gchar *format, ...) } void -wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const gchar c) +wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const char c) { wmem_strbuf_grow(strbuf, 1); @@ -220,7 +220,7 @@ wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const gchar c) } void -wmem_strbuf_append_c_count(wmem_strbuf_t *strbuf, const gchar c, size_t count) +wmem_strbuf_append_c_count(wmem_strbuf_t *strbuf, const char c, size_t count) { wmem_strbuf_grow(strbuf, count); @@ -233,7 +233,7 @@ wmem_strbuf_append_c_count(wmem_strbuf_t *strbuf, const gchar c, size_t count) void wmem_strbuf_append_unichar(wmem_strbuf_t *strbuf, const gunichar c) { - gchar buf[6]; + char buf[6]; size_t charlen; charlen = g_unichar_to_utf8(c, buf); @@ -334,7 +334,7 @@ wmem_strbuf_truncate(wmem_strbuf_t *strbuf, const size_t len) strbuf->len = len; } -const gchar * +const char * wmem_strbuf_get_str(const wmem_strbuf_t *strbuf) { return strbuf->str; @@ -434,7 +434,7 @@ string_utf8_validate(const char *str, ssize_t max_len, const char **endpptr) return string_utf8_validate(str, max_len, endpptr); } -/* g_utf8_validate() returns FALSE in the string contains embedded NUL +/* g_utf8_validate() returns false in the string contains embedded NUL * bytes. We accept \x00 as valid and work around that to validate the * entire len bytes. */ bool diff --git a/wsutil/wmem/wmem_strbuf.h b/wsutil/wmem/wmem_strbuf.h index 68bb62f584..9c00b6e459 100644 --- a/wsutil/wmem/wmem_strbuf.h +++ b/wsutil/wmem/wmem_strbuf.h @@ -42,7 +42,7 @@ extern "C" { struct _wmem_strbuf_t { /* read-only fields */ wmem_allocator_t *allocator; - gchar *str; + char *str; size_t len; /* private fields */ @@ -58,7 +58,7 @@ G_GNUC_MALLOC; WS_DLL_PUBLIC wmem_strbuf_t * -wmem_strbuf_new(wmem_allocator_t *allocator, const gchar *str) +wmem_strbuf_new(wmem_allocator_t *allocator, const char *str) G_GNUC_MALLOC; #define wmem_strbuf_create(allocator) \ @@ -66,7 +66,7 @@ G_GNUC_MALLOC; WS_DLL_PUBLIC wmem_strbuf_t * -wmem_strbuf_new_len(wmem_allocator_t *allocator, const gchar *str, size_t len) +wmem_strbuf_new_len(wmem_allocator_t *allocator, const char *str, size_t len) G_GNUC_MALLOC; WS_DLL_PUBLIC @@ -76,31 +76,31 @@ G_GNUC_MALLOC; WS_DLL_PUBLIC void -wmem_strbuf_append(wmem_strbuf_t *strbuf, const gchar *str); +wmem_strbuf_append(wmem_strbuf_t *strbuf, const char *str); /* Appends up to append_len bytes (as allowed by strbuf->max_size) from * str. Ensures that strbuf is null terminated afterwards but will copy * embedded nulls. */ WS_DLL_PUBLIC void -wmem_strbuf_append_len(wmem_strbuf_t *strbuf, const gchar *str, size_t append_len); +wmem_strbuf_append_len(wmem_strbuf_t *strbuf, const char *str, size_t append_len); WS_DLL_PUBLIC void -wmem_strbuf_append_printf(wmem_strbuf_t *strbuf, const gchar *format, ...) +wmem_strbuf_append_printf(wmem_strbuf_t *strbuf, const char *format, ...) G_GNUC_PRINTF(2, 3); WS_DLL_PUBLIC void -wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const gchar *fmt, va_list ap); +wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const char *fmt, va_list ap); WS_DLL_PUBLIC void -wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const gchar c); +wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const char c); WS_DLL_PUBLIC void -wmem_strbuf_append_c_count(wmem_strbuf_t *strbuf, const gchar c, size_t count); +wmem_strbuf_append_c_count(wmem_strbuf_t *strbuf, const char c, size_t count); WS_DLL_PUBLIC void @@ -130,7 +130,7 @@ void wmem_strbuf_truncate(wmem_strbuf_t *strbuf, const size_t len); WS_DLL_PUBLIC -const gchar * +const char * wmem_strbuf_get_str(const wmem_strbuf_t *strbuf); WS_DLL_PUBLIC diff --git a/wsutil/wmem/wmem_strutl.c b/wsutil/wmem/wmem_strutl.c index 899b11898d..99f1f8c61f 100644 --- a/wsutil/wmem/wmem_strutl.c +++ b/wsutil/wmem/wmem_strutl.c @@ -16,8 +16,8 @@ #include <stdio.h> #include <errno.h> -gchar * -wmem_strdup(wmem_allocator_t *allocator, const gchar *src) +char * +wmem_strdup(wmem_allocator_t *allocator, const char *src) { size_t len; @@ -29,16 +29,16 @@ wmem_strdup(wmem_allocator_t *allocator, const gchar *src) len = strlen(src) + 1; /* +1 for the null-terminator */ - return (gchar *)memcpy(wmem_alloc(allocator, len), src, len); + return (char *)memcpy(wmem_alloc(allocator, len), src, len); } -gchar * -wmem_strndup(wmem_allocator_t *allocator, const gchar *src, const size_t len) +char * +wmem_strndup(wmem_allocator_t *allocator, const char *src, const size_t len) { - gchar *dst; - guint i; + char *dst; + unsigned i; - dst = (gchar *)wmem_alloc(allocator, len+1); + dst = (char *)wmem_alloc(allocator, len+1); for (i=0; (i < len) && src[i]; i++) { dst[i] = src[i]; @@ -49,11 +49,11 @@ wmem_strndup(wmem_allocator_t *allocator, const gchar *src, const size_t len) return dst; } -gchar * -wmem_strdup_printf(wmem_allocator_t *allocator, const gchar *fmt, ...) +char * +wmem_strdup_printf(wmem_allocator_t *allocator, const char *fmt, ...) { va_list ap; - gchar *dst; + char *dst; va_start(ap, fmt); dst = wmem_strdup_vprintf(allocator, fmt, ap); @@ -112,7 +112,7 @@ wmem_strdup_vprintf(wmem_allocator_t *allocator, const char *fmt, va_list ap) /* Return the first occurrence of needle in haystack. * If not found, return NULL. * If either haystack or needle has 0 length, return NULL.*/ -const guint8 * +const uint8_t * ws_memmem(const void *_haystack, size_t haystack_len, const void *_needle, size_t needle_len) { @@ -120,10 +120,10 @@ ws_memmem(const void *_haystack, size_t haystack_len, return memmem(_haystack, haystack_len, _needle, needle_len); #else /* Algorithm copied from GNU's glibc 2.3.2 memmem() under LGPL 2.1+ */ - const guint8 *haystack = _haystack; - const guint8 *needle = _needle; - const guint8 *begin; - const guint8 *const last_possible = haystack + haystack_len - needle_len; + const uint8_t *haystack = _haystack; + const uint8_t *needle = _needle; + const uint8_t *begin; + const uint8_t *const last_possible = haystack + haystack_len - needle_len; if (needle_len == 0) { return NULL; diff --git a/wsutil/wmem/wmem_strutl.h b/wsutil/wmem/wmem_strutl.h index 0af2fa56b9..ee3aed653a 100644 --- a/wsutil/wmem/wmem_strutl.h +++ b/wsutil/wmem/wmem_strutl.h @@ -30,29 +30,29 @@ extern "C" { */ WS_DLL_PUBLIC -gchar * -wmem_strdup(wmem_allocator_t *allocator, const gchar *src) +char * +wmem_strdup(wmem_allocator_t *allocator, const char *src) G_GNUC_MALLOC; #define ws_strdup(src) wmem_strdup(NULL, src) WS_DLL_PUBLIC -gchar * -wmem_strndup(wmem_allocator_t *allocator, const gchar *src, const size_t len) +char * +wmem_strndup(wmem_allocator_t *allocator, const char *src, const size_t len) G_GNUC_MALLOC; #define ws_strndup(src, len) wmem_strndup(NULL, src, len) WS_DLL_PUBLIC -gchar * -wmem_strdup_printf(wmem_allocator_t *allocator, const gchar *fmt, ...) +char * +wmem_strdup_printf(wmem_allocator_t *allocator, const char *fmt, ...) G_GNUC_MALLOC G_GNUC_PRINTF(2, 3); #define ws_strdup_printf(...) wmem_strdup_printf(NULL, __VA_ARGS__) WS_DLL_PUBLIC -gchar * -wmem_strdup_vprintf(wmem_allocator_t *allocator, const gchar *fmt, va_list ap) +char * +wmem_strdup_vprintf(wmem_allocator_t *allocator, const char *fmt, va_list ap) G_GNUC_MALLOC; #define ws_strdup_vprintf(fmt, ap) wmem_strdup_vprintf(NULL, fmt, ap) @@ -69,7 +69,7 @@ G_GNUC_MALLOC; * "needle_len" is 0, NULL is returned. */ WS_DLL_PUBLIC -const guint8 *ws_memmem(const void *haystack, size_t haystack_len, +const uint8_t *ws_memmem(const void *haystack, size_t haystack_len, const void *needle, size_t needle_len); /** @} diff --git a/wsutil/wmem/wmem_test.c b/wsutil/wmem/wmem_test.c index 6ac917fb57..196daf743a 100644 --- a/wsutil/wmem/wmem_test.c +++ b/wsutil/wmem/wmem_test.c @@ -42,7 +42,7 @@ wmem_allocator_force_new(const wmem_allocator_type_t type) allocator = wmem_new(NULL, wmem_allocator_t); allocator->type = type; allocator->callbacks = NULL; - allocator->in_scope = TRUE; + allocator->in_scope = true; switch (type) { case WMEM_ALLOCATOR_SIMPLE: @@ -70,21 +70,21 @@ wmem_allocator_force_new(const wmem_allocator_type_t type) /* A helper for generating pseudo-random strings. Just uses glib's random number * functions to generate 'numbers' in the printable character range. */ -static gchar * -wmem_test_rand_string(wmem_allocator_t *allocator, gint minlen, gint maxlen) +static char * +wmem_test_rand_string(wmem_allocator_t *allocator, int minlen, int maxlen) { - gchar *str; - gint len, i; + char *str; + int len, i; len = g_random_int_range(minlen, maxlen); /* +1 for null-terminator */ - str = (gchar*)wmem_alloc(allocator, len + 1); + str = (char*)wmem_alloc(allocator, len + 1); str[len] = '\0'; for (i=0; i<len; i++) { /* ASCII normal printable range is 32 (space) to 126 (tilde) */ - str[i] = (gchar) g_random_int_range(32, 126); + str[i] = (char) g_random_int_range(32, 126); } return str; @@ -93,10 +93,10 @@ wmem_test_rand_string(wmem_allocator_t *allocator, gint minlen, gint maxlen) static int wmem_test_compare_guint32(const void *a, const void *b) { - guint32 l, r; + uint32_t l, r; - l = *(const guint32*)a; - r = *(const guint32*)b; + l = *(const uint32_t*)a; + r = *(const uint32_t*)b; return l - r; } @@ -107,9 +107,9 @@ void *expected_user_data; wmem_cb_event_t expected_event; int cb_called_count; int cb_continue_count; -gboolean value_seen[CONTAINER_ITERS]; +bool value_seen[CONTAINER_ITERS]; -static gboolean +static bool wmem_test_cb(wmem_allocator_t *allocator, wmem_cb_event_t event, void *user_data) { @@ -118,16 +118,16 @@ wmem_test_cb(wmem_allocator_t *allocator, wmem_cb_event_t event, cb_called_count++; - return *(gboolean*)user_data; + return *(bool*)user_data; } -static gboolean +static bool wmem_test_foreach_cb(const void *key _U_, void *value, void *user_data) { g_assert_true(user_data == expected_user_data); g_assert_true(! value_seen[GPOINTER_TO_INT(value)]); - value_seen[GPOINTER_TO_INT(value)] = TRUE; + value_seen[GPOINTER_TO_INT(value)] = true; cb_called_count++; cb_continue_count--; @@ -141,9 +141,9 @@ static void wmem_test_allocator_callbacks(void) { wmem_allocator_t *allocator; - gboolean t = TRUE; - gboolean f = FALSE; - guint cb_id; + bool t = true; + bool f = false; + unsigned cb_id; allocator = wmem_allocator_new(WMEM_ALLOCATOR_STRICT); @@ -196,7 +196,7 @@ wmem_test_allocator_callbacks(void) static void wmem_test_allocator_det(wmem_allocator_t *allocator, wmem_verify_func verify, - guint len) + unsigned len) { int i; char *ptrs[MAX_SIMULTANEOUS_ALLOCS]; @@ -297,8 +297,8 @@ wmem_test_allocator(wmem_allocator_type_t type, wmem_verify_func verify, /* Run enough iterations to fill the array 32 times */ for (i=0; i<iterations; i++) { - gint ptrs_index; - gint new_size; + int ptrs_index; + int new_size; /* returns value 0 <= x < MAX_SIMULTANEOUS_ALLOCS which is a valid * index into ptrs */ @@ -636,14 +636,14 @@ wmem_test_array(void) wmem_allocator_t *allocator; wmem_array_t *array; unsigned int i, j, k; - guint32 val, *buf; - guint32 vals[8]; - guint32 *raw; - guint32 lastint; + uint32_t val, *buf; + uint32_t vals[8]; + uint32_t *raw; + uint32_t lastint; allocator = wmem_allocator_new(WMEM_ALLOCATOR_STRICT); - array = wmem_array_new(allocator, sizeof(guint32)); + array = wmem_array_new(allocator, sizeof(uint32_t)); g_assert_true(array); g_assert_true(wmem_array_get_count(array) == 0); @@ -652,7 +652,7 @@ wmem_test_array(void) wmem_array_append_one(array, val); g_assert_true(wmem_array_get_count(array) == i+1); - val = *(guint32*)wmem_array_index(array, i); + val = *(uint32_t*)wmem_array_index(array, i); g_assert_true(val == i); g_assert_true(wmem_array_try_index(array, i, &val) == 0); g_assert_true(val == i); @@ -662,7 +662,7 @@ wmem_test_array(void) wmem_strict_check_canaries(allocator); for (i=0; i<CONTAINER_ITERS; i++) { - val = *(guint32*)wmem_array_index(array, i); + val = *(uint32_t*)wmem_array_index(array, i); g_assert_true(val == i); g_assert_true(wmem_array_try_index(array, i, &val) == 0); g_assert_true(val == i); @@ -670,7 +670,7 @@ wmem_test_array(void) wmem_destroy_array(array); - array = wmem_array_sized_new(allocator, sizeof(guint32), 73); + array = wmem_array_sized_new(allocator, sizeof(uint32_t), 73); wmem_array_set_null_terminator(array); for (i=0; i<75; i++) g_assert_true(wmem_array_try_index(array, i, &val) < 0); @@ -685,7 +685,7 @@ wmem_test_array(void) } wmem_strict_check_canaries(allocator); - buf = (guint32*)wmem_array_get_raw(array); + buf = (uint32_t*)wmem_array_get_raw(array); for (i=0; i<CONTAINER_ITERS; i++) { for (j=0; j<8; j++) { g_assert_true(buf[i*8 + j] == i+j); @@ -695,21 +695,21 @@ wmem_test_array(void) wmem_array_sort(array, wmem_test_compare_guint32); for (i=0, k=0; i<8; i++) { for (j=0; j<=i; j++, k++) { - val = *(guint32*)wmem_array_index(array, k); + val = *(uint32_t*)wmem_array_index(array, k); g_assert_true(val == i); g_assert_true(wmem_array_try_index(array, k, &val) == 0); g_assert_true(val == i); } } for (j=k; k<8*(CONTAINER_ITERS+1)-j; k++) { - val = *(guint32*)wmem_array_index(array, k); + val = *(uint32_t*)wmem_array_index(array, k); g_assert_true(val == ((k-j)/8)+8); g_assert_true(wmem_array_try_index(array, k, &val) == 0); g_assert_true(val == ((k-j)/8)+8); } for (i=0; i<7; i++) { for (j=0; j<7-i; j++, k++) { - val = *(guint32*)wmem_array_index(array, k); + val = *(uint32_t*)wmem_array_index(array, k); g_assert_true(val == CONTAINER_ITERS+i); g_assert_true(wmem_array_try_index(array, k, &val) == 0); g_assert_true(val == CONTAINER_ITERS+i); @@ -720,7 +720,7 @@ wmem_test_array(void) lastint = 77; wmem_array_append_one(array, lastint); - raw = (guint32*)wmem_array_get_raw(array); + raw = (uint32_t*)wmem_array_get_raw(array); g_assert_true(raw[wmem_array_get_count(array)] == 0); g_assert_true(raw[wmem_array_get_count(array) - 1] == lastint); @@ -730,12 +730,12 @@ wmem_test_array(void) } static void -check_val_list(gpointer val, gpointer val_to_check) +check_val_list(void * val, void * val_to_check) { g_assert_true(val == val_to_check); } -static gint +static int str_compare(gconstpointer a, gconstpointer b) { return strcmp((const char*)a, (const char*)b); @@ -889,13 +889,13 @@ wmem_test_list(void) } static void -check_val_map(gpointer key _U_, gpointer val, gpointer user_data) +check_val_map(void * key _U_, void * val, void * user_data) { g_assert_true(val == user_data); } static gboolean -equal_val_map(gpointer key _U_, gpointer val, gpointer user_data) +equal_val_map(void * key _U_, void * val, void * user_data) { return val == user_data; } @@ -905,7 +905,7 @@ wmem_test_map(void) { wmem_allocator_t *allocator, *extra_allocator; wmem_map_t *map; - gchar *str_key; + char *str_key; const void *str_key_ret; unsigned int i; unsigned int *key_ret; @@ -930,7 +930,7 @@ wmem_test_map(void) for (i=0; i<CONTAINER_ITERS; i++) { ret = wmem_map_lookup(map, GINT_TO_POINTER(i)); g_assert_true(ret == GINT_TO_POINTER(i)); - g_assert_true(wmem_map_contains(map, GINT_TO_POINTER(i)) == TRUE); + g_assert_true(wmem_map_contains(map, GINT_TO_POINTER(i)) == true); g_assert_true(wmem_map_lookup_extended(map, GINT_TO_POINTER(i), NULL, NULL)); key_ret = NULL; g_assert_true(wmem_map_lookup_extended(map, GINT_TO_POINTER(i), GINT_TO_POINTER(&key_ret), NULL)); @@ -945,7 +945,7 @@ wmem_test_map(void) g_assert_true(value_ret == GINT_TO_POINTER(i)); ret = wmem_map_remove(map, GINT_TO_POINTER(i)); g_assert_true(ret == GINT_TO_POINTER(i)); - g_assert_true(wmem_map_contains(map, GINT_TO_POINTER(i)) == FALSE); + g_assert_true(wmem_map_contains(map, GINT_TO_POINTER(i)) == false); ret = wmem_map_lookup(map, GINT_TO_POINTER(i)); g_assert_true(ret == NULL); ret = wmem_map_remove(map, GINT_TO_POINTER(i)); @@ -979,10 +979,10 @@ wmem_test_map(void) wmem_map_insert(map, str_key, GINT_TO_POINTER(i)); ret = wmem_map_lookup(map, str_key); g_assert_true(ret == GINT_TO_POINTER(i)); - g_assert_true(wmem_map_contains(map, str_key) == TRUE); + g_assert_true(wmem_map_contains(map, str_key) == true); str_key_ret = NULL; value_ret = NULL; - g_assert_true(wmem_map_lookup_extended(map, str_key, &str_key_ret, GINT_TO_POINTER(&value_ret)) == TRUE); + g_assert_true(wmem_map_lookup_extended(map, str_key, &str_key_ret, GINT_TO_POINTER(&value_ret)) == true); g_assert_true(g_str_equal(str_key_ret, str_key)); g_assert_true(value_ret == GINT_TO_POINTER(i)); } @@ -1182,10 +1182,10 @@ wmem_test_tree(void) { wmem_allocator_t *allocator, *extra_allocator; wmem_tree_t *tree; - guint32 i; + uint32_t i; int seen_values = 0; int j; - gchar *str_key; + char *str_key; #define WMEM_TREE_MAX_KEY_COUNT 8 #define WMEM_TREE_MAX_KEY_LEN 4 int key_count; @@ -1213,7 +1213,7 @@ wmem_test_tree(void) tree = wmem_tree_new(allocator); for (i=0; i<CONTAINER_ITERS; i++) { - guint32 rand_int; + uint32_t rand_int; do { rand_int = g_test_rand_int(); } while (wmem_tree_lookup32(tree, rand_int)); @@ -1248,7 +1248,7 @@ wmem_test_tree(void) keys[key_count].length = 0; for (i=0; i<CONTAINER_ITERS; i++) { for (j=0; j<key_count; j++) { - keys[j].key = (guint32*)wmem_test_rand_string(allocator, + keys[j].key = (uint32_t*)wmem_test_rand_string(allocator, (keys[j].length*4), (keys[j].length*4)+1); } wmem_tree_insert32_array(tree, keys, GINT_TO_POINTER(i)); @@ -1258,7 +1258,7 @@ wmem_test_tree(void) tree = wmem_tree_new(allocator); keys[0].length = 1; - keys[0].key = wmem_new(allocator, guint32); + keys[0].key = wmem_new(allocator, uint32_t); *(keys[0].key) = 0; keys[1].length = 0; for (i=0; i<CONTAINER_ITERS; i++) { @@ -1301,11 +1301,11 @@ wmem_test_tree(void) tree = wmem_tree_new(allocator); expected_user_data = GINT_TO_POINTER(g_test_rand_int()); for (i=0; i<CONTAINER_ITERS; i++) { - gint tmp; + int tmp; do { tmp = g_test_rand_int(); } while (wmem_tree_lookup32(tree, tmp)); - value_seen[i] = FALSE; + value_seen[i] = false; wmem_tree_insert32(tree, tmp, GINT_TO_POINTER(i)); } @@ -1317,7 +1317,7 @@ wmem_test_tree(void) for (i=0; i<CONTAINER_ITERS; i++) { g_assert_true(value_seen[i]); - value_seen[i] = FALSE; + value_seen[i] = false; } cb_called_count = 0; @@ -1341,12 +1341,12 @@ wmem_test_tree(void) /* to be used as userdata in the callback wmem_test_itree_check_overlap_cb*/ typedef struct wmem_test_itree_user_data { wmem_range_t range; - guint counter; + unsigned counter; } wmem_test_itree_user_data_t; /* increase userData counter in case the range match the userdata range */ -static gboolean +static bool wmem_test_itree_check_overlap_cb (const void *key, void *value _U_, void *userData) { const wmem_range_t *ckey = (const wmem_range_t *)key; @@ -1358,12 +1358,12 @@ wmem_test_itree_check_overlap_cb (const void *key, void *value _U_, void *userDa d->counter++; } - return FALSE; + return false; } -static gboolean -wmem_test_overlap(guint64 low, guint64 high, guint64 lowbis, guint64 highbis) +static bool +wmem_test_overlap(uint64_t low, uint64_t high, uint64_t lowbis, uint64_t highbis) { wmem_range_t r1 = {low, high, 0}; wmem_range_t r2 = {lowbis, highbis, 0}; @@ -1376,7 +1376,7 @@ wmem_test_itree(void) wmem_allocator_t *allocator, *extra_allocator; wmem_itree_t *tree; int i = 0; - gint32 max_rand = 0; + int32_t max_rand = 0; wmem_test_itree_user_data_t userData; wmem_range_t range, r2; @@ -1411,7 +1411,7 @@ wmem_test_itree(void) max_rand = G_MAXINT32; r2.max_edge = range.max_edge = 0; range.low = g_test_rand_int_range(0, max_rand); - range.high = g_test_rand_int_range( (gint32)range.low, (gint32)max_rand); + range.high = g_test_rand_int_range( (int32_t)range.low, (int32_t)max_rand); userData.range = range; for (i=0; i<CONTAINER_ITERS; i++) { @@ -1420,8 +1420,8 @@ wmem_test_itree(void) /* reset the search */ userData.counter = 0; - r2.low = (guint64)g_test_rand_int_range(0, 100); - r2.high = (guint64)g_test_rand_int_range( (gint32)r2.low, 100); + r2.low = (uint64_t)g_test_rand_int_range(0, 100); + r2.high = (uint64_t)g_test_rand_int_range( (int32_t)r2.low, 100); wmem_itree_insert(tree, r2.low, r2.high, GINT_TO_POINTER(i)); diff --git a/wsutil/wmem/wmem_tree-int.h b/wsutil/wmem/wmem_tree-int.h index 3dc6de866a..d6b6cc105e 100644 --- a/wsutil/wmem/wmem_tree-int.h +++ b/wsutil/wmem/wmem_tree-int.h @@ -34,8 +34,8 @@ struct _wmem_tree_node_t { void *data; wmem_node_color_t color; - gboolean is_subtree; - gboolean is_removed; + bool is_subtree; + bool is_removed; }; @@ -49,8 +49,8 @@ struct _wmem_tree_t { wmem_allocator_t *metadata_allocator; wmem_allocator_t *data_allocator; wmem_tree_node_t *root; - guint metadata_scope_cb_id; - guint data_scope_cb_id; + unsigned metadata_scope_cb_id; + unsigned data_scope_cb_id; void (*post_rotation_cb)(wmem_tree_node_t *); }; @@ -62,7 +62,7 @@ wmem_tree_insert(wmem_tree_t *tree, const void *key, void *data, compare_func cm typedef struct _wmem_range_t wmem_range_t; -gboolean +bool wmem_itree_range_overlap(const wmem_range_t *r1, const wmem_range_t *r2); #ifdef __cplusplus diff --git a/wsutil/wmem/wmem_tree.c b/wsutil/wmem/wmem_tree.c index 826a49eeea..05fa638e74 100644 --- a/wsutil/wmem/wmem_tree.c +++ b/wsutil/wmem/wmem_tree.c @@ -205,7 +205,7 @@ wmem_tree_new(wmem_allocator_t *allocator) return tree; } -static gboolean +static bool wmem_tree_reset_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event, void *user_data) { @@ -218,10 +218,10 @@ wmem_tree_reset_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event, wmem_free(tree->metadata_allocator, tree); } - return TRUE; + return true; } -static gboolean +static bool wmem_tree_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, void *user_data) { @@ -229,7 +229,7 @@ wmem_tree_destroy_cb(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_, wmem_unregister_callback(tree->data_allocator, tree->data_scope_cb_id); - return FALSE; + return false; } wmem_tree_t * @@ -250,7 +250,7 @@ wmem_tree_new_autoreset(wmem_allocator_t *metadata_scope, wmem_allocator_t *data } static void -free_tree_node(wmem_allocator_t *allocator, wmem_tree_node_t* node, gboolean free_keys, gboolean free_values) +free_tree_node(wmem_allocator_t *allocator, wmem_tree_node_t* node, bool free_keys, bool free_values) { if (node == NULL) { return; @@ -280,7 +280,7 @@ free_tree_node(wmem_allocator_t *allocator, wmem_tree_node_t* node, gboolean fre } void -wmem_tree_destroy(wmem_tree_t *tree, gboolean free_keys, gboolean free_values) +wmem_tree_destroy(wmem_tree_t *tree, bool free_keys, bool free_values) { free_tree_node(tree->data_allocator, tree->root, free_keys, free_values); if (tree->metadata_allocator) { @@ -292,24 +292,24 @@ wmem_tree_destroy(wmem_tree_t *tree, gboolean free_keys, gboolean free_values) wmem_free(tree->metadata_allocator, tree); } -gboolean +bool wmem_tree_is_empty(wmem_tree_t *tree) { return tree->root == NULL; } -static gboolean +static bool count_nodes(const void *key _U_, void *value _U_, void *userdata) { - guint* count = (guint*)userdata; + unsigned* count = (unsigned*)userdata; (*count)++; - return FALSE; + return false; } -guint +unsigned wmem_tree_count(wmem_tree_t* tree) { - guint count = 0; + unsigned count = 0; /* Recursing through the tree counting each node is the simplest approach. We don't keep track of the count within the tree because it can get @@ -321,7 +321,7 @@ wmem_tree_count(wmem_tree_t* tree) static wmem_tree_node_t * create_node(wmem_allocator_t *allocator, wmem_tree_node_t *parent, const void *key, - void *data, wmem_node_color_t color, gboolean is_subtree) + void *data, wmem_node_color_t color, bool is_subtree) { wmem_tree_node_t *node; @@ -336,7 +336,7 @@ create_node(wmem_allocator_t *allocator, wmem_tree_node_t *parent, const void *k node->color = color; node->is_subtree = is_subtree; - node->is_removed = FALSE; + node->is_removed = false; return node; } @@ -348,8 +348,8 @@ create_node(wmem_allocator_t *allocator, wmem_tree_node_t *parent, const void *k * return inserted node */ static wmem_tree_node_t * -lookup_or_insert32_node(wmem_tree_t *tree, guint32 key, - void*(*func)(void*), void* data, gboolean is_subtree, gboolean replace) +lookup_or_insert32_node(wmem_tree_t *tree, uint32_t key, + void*(*func)(void*), void* data, bool is_subtree, bool replace) { wmem_tree_node_t *node = tree->root; wmem_tree_node_t *new_node = NULL; @@ -407,8 +407,8 @@ lookup_or_insert32_node(wmem_tree_t *tree, guint32 key, static void * -lookup_or_insert32(wmem_tree_t *tree, guint32 key, - void*(*func)(void*), void* data, gboolean is_subtree, gboolean replace) +lookup_or_insert32(wmem_tree_t *tree, uint32_t key, + void*(*func)(void*), void* data, bool is_subtree, bool replace) { wmem_tree_node_t *node = lookup_or_insert32_node(tree, key, func, data, is_subtree, replace); return node->data; @@ -450,7 +450,7 @@ wmem_tree_insert(wmem_tree_t *tree, const void *key, void *data, compare_func cm /* is this the first node ?*/ if (!node) { tree->root = create_node(tree->data_allocator, node, key, - data, WMEM_NODE_COLOR_BLACK, FALSE); + data, WMEM_NODE_COLOR_BLACK, false); return tree->root; } @@ -461,7 +461,7 @@ wmem_tree_insert(wmem_tree_t *tree, const void *key, void *data, compare_func cm int result = cmp(key, node->key); if (result == 0) { node->data = data; - node->is_removed = data ? FALSE : TRUE; + node->is_removed = data ? false : true; return node; } else if (result < 0) { @@ -470,7 +470,7 @@ wmem_tree_insert(wmem_tree_t *tree, const void *key, void *data, compare_func cm } else { new_node = create_node(tree->data_allocator, node, key, - data, WMEM_NODE_COLOR_RED, FALSE); + data, WMEM_NODE_COLOR_RED, false); node->left = new_node; } } @@ -481,7 +481,7 @@ wmem_tree_insert(wmem_tree_t *tree, const void *key, void *data, compare_func cm else { /* new node to the right */ new_node = create_node(tree->data_allocator, node, key, - data, WMEM_NODE_COLOR_RED, FALSE); + data, WMEM_NODE_COLOR_RED, false); node->right = new_node; } } @@ -494,22 +494,22 @@ wmem_tree_insert(wmem_tree_t *tree, const void *key, void *data, compare_func cm } void -wmem_tree_insert32(wmem_tree_t *tree, guint32 key, void *data) +wmem_tree_insert32(wmem_tree_t *tree, uint32_t key, void *data) { - lookup_or_insert32(tree, key, NULL, data, FALSE, TRUE); + lookup_or_insert32(tree, key, NULL, data, false, true); } -gboolean wmem_tree_contains32(wmem_tree_t *tree, guint32 key) +bool wmem_tree_contains32(wmem_tree_t *tree, uint32_t key) { if (!tree) { - return FALSE; + return false; } wmem_tree_node_t *node = tree->root; while (node) { if (key == GPOINTER_TO_UINT(node->key)) { - return TRUE; + return true; } else if (key < GPOINTER_TO_UINT(node->key)) { node = node->left; @@ -519,11 +519,11 @@ gboolean wmem_tree_contains32(wmem_tree_t *tree, guint32 key) } } - return FALSE; + return false; } void * -wmem_tree_lookup32(wmem_tree_t *tree, guint32 key) +wmem_tree_lookup32(wmem_tree_t *tree, uint32_t key) { if (!tree) { return NULL; @@ -547,7 +547,7 @@ wmem_tree_lookup32(wmem_tree_t *tree, guint32 key) } void * -wmem_tree_lookup32_le(wmem_tree_t *tree, guint32 key) +wmem_tree_lookup32_le(wmem_tree_t *tree, uint32_t key) { if (!tree) { return NULL; @@ -613,7 +613,7 @@ wmem_tree_lookup32_le(wmem_tree_t *tree, guint32 key) } void * -wmem_tree_remove32(wmem_tree_t *tree, guint32 key) +wmem_tree_remove32(wmem_tree_t *tree, uint32_t key) { void *ret = wmem_tree_lookup32(tree, key); if (ret) { @@ -624,7 +624,7 @@ wmem_tree_remove32(wmem_tree_t *tree, guint32 key) } void -wmem_tree_insert_string(wmem_tree_t* tree, const gchar* k, void* v, guint32 flags) +wmem_tree_insert_string(wmem_tree_t* tree, const char* k, void* v, uint32_t flags) { char *key; compare_func cmp; @@ -641,7 +641,7 @@ wmem_tree_insert_string(wmem_tree_t* tree, const gchar* k, void* v, guint32 flag } void * -wmem_tree_lookup_string(wmem_tree_t* tree, const gchar* k, guint32 flags) +wmem_tree_lookup_string(wmem_tree_t* tree, const char* k, uint32_t flags) { compare_func cmp; @@ -655,7 +655,7 @@ wmem_tree_lookup_string(wmem_tree_t* tree, const gchar* k, guint32 flags) } void * -wmem_tree_remove_string(wmem_tree_t* tree, const gchar* k, guint32 flags) +wmem_tree_remove_string(wmem_tree_t* tree, const char* k, uint32_t flags) { void *ret = wmem_tree_lookup_string(tree, k, flags); if (ret) { @@ -676,7 +676,7 @@ wmem_tree_insert32_array(wmem_tree_t *tree, wmem_tree_key_t *key, void *data) { wmem_tree_t *insert_tree = NULL; wmem_tree_key_t *cur_key; - guint32 i, insert_key32 = 0; + uint32_t i, insert_key32 = 0; for (cur_key = key; cur_key->length > 0; cur_key++) { for (i = 0; i < cur_key->length; i++) { @@ -685,7 +685,7 @@ wmem_tree_insert32_array(wmem_tree_t *tree, wmem_tree_key_t *key, void *data) insert_tree = tree; } else { insert_tree = (wmem_tree_t *)lookup_or_insert32(insert_tree, - insert_key32, create_sub_tree, tree, TRUE, FALSE); + insert_key32, create_sub_tree, tree, true, false); } insert_key32 = cur_key->key[i]; } @@ -698,11 +698,11 @@ wmem_tree_insert32_array(wmem_tree_t *tree, wmem_tree_key_t *key, void *data) static void * wmem_tree_lookup32_array_helper(wmem_tree_t *tree, wmem_tree_key_t *key, - void*(*helper)(wmem_tree_t*, guint32)) + void*(*helper)(wmem_tree_t*, uint32_t)) { wmem_tree_t *lookup_tree = NULL; wmem_tree_key_t *cur_key; - guint32 i, lookup_key32 = 0; + uint32_t i, lookup_key32 = 0; if (!tree || !key) { return NULL; @@ -743,19 +743,19 @@ wmem_tree_lookup32_array_le(wmem_tree_t *tree, wmem_tree_key_t *key) return wmem_tree_lookup32_array_helper(tree, key, wmem_tree_lookup32_le); } -static gboolean +static bool wmem_tree_foreach_nodes(wmem_tree_node_t* node, wmem_foreach_func callback, void *user_data) { - gboolean stop_traverse = FALSE; + bool stop_traverse = false; if (!node) { - return FALSE; + return false; } if (node->left) { if (wmem_tree_foreach_nodes(node->left, callback, user_data)) { - return TRUE; + return true; } } @@ -768,40 +768,40 @@ wmem_tree_foreach_nodes(wmem_tree_node_t* node, wmem_foreach_func callback, } if (stop_traverse) { - return TRUE; + return true; } if(node->right) { if (wmem_tree_foreach_nodes(node->right, callback, user_data)) { - return TRUE; + return true; } } - return FALSE; + return false; } -gboolean +bool wmem_tree_foreach(wmem_tree_t* tree, wmem_foreach_func callback, void *user_data) { if(!tree->root) - return FALSE; + return false; return wmem_tree_foreach_nodes(tree->root, callback, user_data); } -static void wmem_print_subtree(wmem_tree_t *tree, guint32 level, wmem_printer_func key_printer, wmem_printer_func data_printer); +static void wmem_print_subtree(wmem_tree_t *tree, uint32_t level, wmem_printer_func key_printer, wmem_printer_func data_printer); static void -wmem_print_indent(guint32 level) { - guint32 i; +wmem_print_indent(uint32_t level) { + uint32_t i; for (i=0; i<level; i++) { printf(" "); } } static void -wmem_tree_print_nodes(const char *prefix, wmem_tree_node_t *node, guint32 level, +wmem_tree_print_nodes(const char *prefix, wmem_tree_node_t *node, uint32_t level, wmem_printer_func key_printer, wmem_printer_func data_printer) { if (!node) @@ -837,7 +837,7 @@ wmem_tree_print_nodes(const char *prefix, wmem_tree_node_t *node, guint32 level, static void -wmem_print_subtree(wmem_tree_t *tree, guint32 level, wmem_printer_func key_printer, wmem_printer_func data_printer) +wmem_print_subtree(wmem_tree_t *tree, uint32_t level, wmem_printer_func key_printer, wmem_printer_func data_printer) { if (!tree) return; diff --git a/wsutil/wmem/wmem_tree.h b/wsutil/wmem/wmem_tree.h index 6105a4cb02..f639ff9ad0 100644 --- a/wsutil/wmem/wmem_tree.h +++ b/wsutil/wmem/wmem_tree.h @@ -63,19 +63,19 @@ G_GNUC_MALLOC; /** Cleanup memory used by tree. Intended for NULL scope allocated trees */ WS_DLL_PUBLIC void -wmem_tree_destroy(wmem_tree_t *tree, gboolean free_keys, gboolean free_values); +wmem_tree_destroy(wmem_tree_t *tree, bool free_keys, bool free_values); /** Returns true if the tree is empty (has no nodes). */ WS_DLL_PUBLIC -gboolean +bool wmem_tree_is_empty(wmem_tree_t *tree); /** Returns number of nodes in tree */ WS_DLL_PUBLIC -guint +unsigned wmem_tree_count(wmem_tree_t* tree); -/** Insert a node indexed by a guint32 key value. +/** Insert a node indexed by a uint32_t key value. * * Data is a pointer to the structure you want to be able to retrieve by * searching for the same key later. @@ -88,42 +88,42 @@ wmem_tree_count(wmem_tree_t* tree); */ WS_DLL_PUBLIC void -wmem_tree_insert32(wmem_tree_t *tree, guint32 key, void *data); +wmem_tree_insert32(wmem_tree_t *tree, uint32_t key, void *data); -/** Look up a node in the tree indexed by a guint32 integer value. Return TRUE +/** Look up a node in the tree indexed by a uint32_t integer value. Return true * if present. */ WS_DLL_PUBLIC -gboolean -wmem_tree_contains32(wmem_tree_t *tree, guint32 key); +bool +wmem_tree_contains32(wmem_tree_t *tree, uint32_t key); -/** Look up a node in the tree indexed by a guint32 integer value. If no node is +/** Look up a node in the tree indexed by a uint32_t integer value. If no node is * found the function will return NULL. */ WS_DLL_PUBLIC void * -wmem_tree_lookup32(wmem_tree_t *tree, guint32 key); +wmem_tree_lookup32(wmem_tree_t *tree, uint32_t key); -/** Look up a node in the tree indexed by a guint32 integer value. +/** Look up a node in the tree indexed by a uint32_t integer value. * Returns the node that has the largest key that is less than or equal * to the search key, or NULL if no such key exists. */ WS_DLL_PUBLIC void * -wmem_tree_lookup32_le(wmem_tree_t *tree, guint32 key); +wmem_tree_lookup32_le(wmem_tree_t *tree, uint32_t key); -/** Remove a node in the tree indexed by a guint32 integer value. This is not +/** Remove a node in the tree indexed by a uint32_t integer value. This is not * really a remove, but the value is set to NULL so that wmem_tree_lookup32 * not will find it. */ WS_DLL_PUBLIC void * -wmem_tree_remove32(wmem_tree_t *tree, guint32 key); +wmem_tree_remove32(wmem_tree_t *tree, uint32_t key); /** case insensitive strings as keys */ #define WMEM_TREE_STRING_NOCASE 0x00000001 /** Insert a new value under a string key. Like wmem_tree_insert32 but where the - * key is a null-terminated string instead of a guint32. You may pass + * key is a null-terminated string instead of a uint32_t. You may pass * WMEM_TREE_STRING_NOCASE to the flags argument in order to make it store the * key in a case-insensitive way. (Note that "case-insensitive" refers * only to the ASCII letters A-Z and a-z; it is locale-independent. @@ -131,36 +131,36 @@ wmem_tree_remove32(wmem_tree_t *tree, guint32 key); * will always be mapped to "i". */ WS_DLL_PUBLIC void -wmem_tree_insert_string(wmem_tree_t *tree, const gchar* key, void *data, - guint32 flags); +wmem_tree_insert_string(wmem_tree_t *tree, const char* key, void *data, + uint32_t flags); /** Lookup the value under a string key, like wmem_tree_lookup32 but where the - * keye is a null-terminated string instead of a guint32. See + * keye is a null-terminated string instead of a uint32_t. See * wmem_tree_insert_string for an explanation of flags. */ WS_DLL_PUBLIC void * -wmem_tree_lookup_string(wmem_tree_t* tree, const gchar* key, guint32 flags); +wmem_tree_lookup_string(wmem_tree_t* tree, const char* key, uint32_t flags); /** Remove the value under a string key. This is not really a remove, but the * value is set to NULL so that wmem_tree_lookup_string not will find it. * See wmem_tree_insert_string for an explanation of flags. */ WS_DLL_PUBLIC void * -wmem_tree_remove_string(wmem_tree_t* tree, const gchar* key, guint32 flags); +wmem_tree_remove_string(wmem_tree_t* tree, const char* key, uint32_t flags); typedef struct _wmem_tree_key_t { - guint32 length; /**< length in guint32 words */ - guint32 *key; + uint32_t length; /**< length in uint32_t words */ + uint32_t *key; } wmem_tree_key_t; -/** Insert a node indexed by a sequence of guint32 key values. +/** Insert a node indexed by a sequence of uint32_t key values. * - * Takes as key an array of guint32 vectors of type wmem_tree_key_t. It will + * Takes as key an array of uint32_t vectors of type wmem_tree_key_t. It will * iterate through each key to search further down the tree until it reaches an * element where length==0, indicating the end of the array. You MUST terminate * the key array by {0, NULL} or this will crash. * - * NOTE: length indicates the number of guint32 values in the vector, not the + * NOTE: length indicates the number of uint32_t values in the vector, not the * number of bytes. * * NOTE: all the "key" members of the "key" argument MUST be aligned on @@ -176,7 +176,7 @@ typedef struct _wmem_tree_key_t { * nfs_name_snoop_known tree which holds filehandles for both v2 and v3. * v2 filehandles are always 32 bytes (8 words) while v3 filehandles can have * any length (though 32 bytes are most common). - * The NFS dissector handles this by providing a guint32 containing the length + * The NFS dissector handles this by providing a uint32_t containing the length * as the very first item in this vector : * * wmem_tree_key_t fhkey[3]; @@ -192,7 +192,7 @@ WS_DLL_PUBLIC void wmem_tree_insert32_array(wmem_tree_t *tree, wmem_tree_key_t *key, void *data); -/** Look up a node in the tree indexed by a sequence of guint32 integer values. +/** Look up a node in the tree indexed by a sequence of uint32_t integer values. * See wmem_tree_insert32_array for details on the key. */ WS_DLL_PUBLIC @@ -215,9 +215,9 @@ wmem_tree_lookup32_array_le(wmem_tree_t *tree, wmem_tree_key_t *key); /** Function type for processing one node of a tree during a traversal. Value is * the value of the node, userdata is whatever was passed to the traversal - * function. If the function returns TRUE the traversal will end prematurely. + * function. If the function returns true the traversal will end prematurely. */ -typedef gboolean (*wmem_foreach_func)(const void *key, void *value, void *userdata); +typedef bool (*wmem_foreach_func)(const void *key, void *value, void *userdata); /** Function type to print key/data of nodes in wmem_print_tree_verbose */ @@ -227,10 +227,10 @@ typedef void (*wmem_printer_func)(const void *data); /** Inorder traversal (left/parent/right) of the tree and call * callback(value, userdata) for each value found. * - * Returns TRUE if the traversal was ended prematurely by the callback. + * Returns true if the traversal was ended prematurely by the callback. */ WS_DLL_PUBLIC -gboolean +bool wmem_tree_foreach(wmem_tree_t* tree, wmem_foreach_func callback, void *user_data); diff --git a/wsutil/wmem/wmem_user_cb.c b/wsutil/wmem/wmem_user_cb.c index c9b02c2e17..232b16929a 100644 --- a/wsutil/wmem/wmem_user_cb.c +++ b/wsutil/wmem/wmem_user_cb.c @@ -19,14 +19,14 @@ typedef struct _wmem_user_cb_container_t { wmem_user_cb_t cb; void *user_data; struct _wmem_user_cb_container_t *next; - guint id; + unsigned id; } wmem_user_cb_container_t; void wmem_call_callbacks(wmem_allocator_t *allocator, wmem_cb_event_t event) { wmem_user_cb_container_t **prev, *cur; - gboolean again; + bool again; prev = &(allocator->callbacks); cur = allocator->callbacks; @@ -50,12 +50,12 @@ wmem_call_callbacks(wmem_allocator_t *allocator, wmem_cb_event_t event) } } -guint +unsigned wmem_register_callback(wmem_allocator_t *allocator, wmem_user_cb_t callback, void *user_data) { wmem_user_cb_container_t *container; - static guint next_id = 1; + static unsigned next_id = 1; container = wmem_new(NULL, wmem_user_cb_container_t); @@ -70,7 +70,7 @@ wmem_register_callback(wmem_allocator_t *allocator, } void -wmem_unregister_callback(wmem_allocator_t *allocator, guint id) +wmem_unregister_callback(wmem_allocator_t *allocator, unsigned id) { wmem_user_cb_container_t **prev, *cur; diff --git a/wsutil/wmem/wmem_user_cb.h b/wsutil/wmem/wmem_user_cb.h index 236f55ebb1..7d2a37e396 100644 --- a/wsutil/wmem/wmem_user_cb.h +++ b/wsutil/wmem/wmem_user_cb.h @@ -39,9 +39,9 @@ typedef enum _wmem_cb_event_t { * event The event type that triggered this callback. * user_data Whatever user_data was originally passed to the call to * wmem_register_callback(). - * @return FALSE to unregister the callback, TRUE otherwise. + * @return false to unregister the callback, true otherwise. */ -typedef gboolean (*wmem_user_cb_t) (wmem_allocator_t*, wmem_cb_event_t, void*); +typedef bool (*wmem_user_cb_t) (wmem_allocator_t*, wmem_cb_event_t, void*); /** Register a callback function with the given allocator pool. * @@ -56,7 +56,7 @@ typedef gboolean (*wmem_user_cb_t) (wmem_allocator_t*, wmem_cb_event_t, void*); * wmem_unregister_callback(). */ WS_DLL_PUBLIC -guint +unsigned wmem_register_callback(wmem_allocator_t *allocator, wmem_user_cb_t callback, void *user_data); @@ -67,7 +67,7 @@ wmem_register_callback(wmem_allocator_t *allocator, wmem_user_cb_t callback, */ WS_DLL_PUBLIC void -wmem_unregister_callback(wmem_allocator_t *allocator, guint id); +wmem_unregister_callback(wmem_allocator_t *allocator, unsigned id); /** @} * @} */ |