summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-01-13 15:13:40 -0800
committerGuy Harris <guy@alum.mit.edu>2015-01-13 23:14:13 +0000
commit63a3d043e3f14eebb0798a250d9aecdc8e89dfb9 (patch)
tree69a58dd4cadfc7f98669cba229e76fa8c60e0761 /epan
parent9f5e4fb7a51741a286ce5bc92a6f335ed58587a2 (diff)
downloadwireshark-63a3d043e3f14eebb0798a250d9aecdc8e89dfb9.tar.gz
Consistently use the "g_string_free returns a C string pointer" idiom.
g_string_free(str, FALSE) frees the GString container but not the underlying g_malloc()ed string; instead, it returns a pointer to the g_malloc()ed string. Fix those places that didn't already get the string pointer from g_string_free() to do so rather than manually extracting the string themselves. And fix one place that didn't even need to use a string - it was just scanning a C string without even modifying it. Change-Id: Ibbf4872bf5b9935b9907f539b6edb1013f3053a5 Reviewed-on: https://code.wireshark.org/review/6532 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r--epan/conversation_table.c6
-rw-r--r--epan/dfilter/dfilter-macro.c6
-rw-r--r--epan/dissectors/packet-xml.c5
-rw-r--r--epan/geoip_db.c5
-rw-r--r--epan/oids.c5
-rw-r--r--epan/radius_dict.l6
6 files changed, 9 insertions, 24 deletions
diff --git a/epan/conversation_table.c b/epan/conversation_table.c
index b857b20e3c..3f9f1e631e 100644
--- a/epan/conversation_table.c
+++ b/epan/conversation_table.c
@@ -168,13 +168,12 @@ set_conv_gui_data(gpointer data, gpointer user_data)
cmd_string_list_ = g_list_append(cmd_string_list_, conv_cmd_str->str);
ui_info.group = REGISTER_STAT_GROUP_CONVERSATION_LIST;
ui_info.title = NULL; /* construct this from the protocol info? */
- ui_info.cli_string = conv_cmd_str->str;
+ ui_info.cli_string = g_string_free(conv_cmd_str, FALSE);
ui_info.tap_init_cb = dissector_conversation_init;
ui_info.index = -1;
ui_info.nparams = 0;
ui_info.params = NULL;
register_stat_tap_ui(&ui_info, table);
- g_string_free(conv_cmd_str, FALSE);
}
void conversation_table_set_gui_info(conv_gui_init_cb init_cb)
@@ -194,13 +193,12 @@ set_host_gui_data(gpointer data, gpointer user_data)
g_string_printf(host_cmd_str, "%s,%s", HOSTLIST_TAP_PREFIX, proto_get_protocol_filter_name(table->proto_id));
ui_info.group = REGISTER_STAT_GROUP_ENDPOINT_LIST;
ui_info.title = NULL; /* construct this from the protocol info? */
- ui_info.cli_string = host_cmd_str->str;
+ ui_info.cli_string = g_string_free(host_cmd_str, FALSE);
ui_info.tap_init_cb = dissector_hostlist_init;
ui_info.index = -1;
ui_info.nparams = 0;
ui_info.params = NULL;
register_stat_tap_ui(&ui_info, table);
- g_string_free(host_cmd_str, FALSE);
}
void hostlist_table_set_gui_info(host_gui_init_cb init_cb)
diff --git a/epan/dfilter/dfilter-macro.c b/epan/dfilter/dfilter-macro.c
index ed2f245374..fef1f2c561 100644
--- a/epan/dfilter/dfilter-macro.c
+++ b/epan/dfilter/dfilter-macro.c
@@ -318,8 +318,7 @@ static const gchar* dfilter_macro_apply_recurse(const gchar* text, guint depth,
*error = "end of filter in the middle of a macro expression";
goto on_error;
} case ';': {
- g_ptr_array_add(args,arg->str);
- g_string_free(arg,FALSE);
+ g_ptr_array_add(args,g_string_free(arg,FALSE));
arg = g_string_sized_new(32);
break;
@@ -337,10 +336,9 @@ static const gchar* dfilter_macro_apply_recurse(const gchar* text, guint depth,
break;
} case '}': {
const gchar* resolved;
- g_ptr_array_add(args,arg->str);
+ g_ptr_array_add(args,g_string_free(arg,FALSE));
g_ptr_array_add(args,NULL);
- g_string_free(arg,FALSE);
arg = NULL;
resolved = dfilter_macro_resolve(name->str, (gchar**)args->pdata, error);
diff --git a/epan/dissectors/packet-xml.c b/epan/dissectors/packet-xml.c
index b419d24ba7..c54553a891 100644
--- a/epan/dissectors/packet-xml.c
+++ b/epan/dissectors/packet-xml.c
@@ -922,7 +922,6 @@ static gchar *fully_qualified_name(GPtrArray *hier, gchar *name, gchar *proto_na
{
guint i;
GString *s = g_string_new(proto_name);
- gchar *str;
g_string_append(s, ".");
@@ -931,10 +930,8 @@ static gchar *fully_qualified_name(GPtrArray *hier, gchar *name, gchar *proto_na
}
g_string_append(s, name);
- str = s->str;
- g_string_free(s, FALSE);
- return str;
+ return g_string_free(s, FALSE);
}
diff --git a/epan/geoip_db.c b/epan/geoip_db.c
index 070460ff7e..3b1ce0cbf2 100644
--- a/epan/geoip_db.c
+++ b/epan/geoip_db.c
@@ -511,7 +511,6 @@ geoip_db_lookup_ipv6(guint dbnum _U_, struct e_in6_addr addr _U_, const char *no
gchar *
geoip_db_get_paths(void) {
GString* path_str = NULL;
- gchar *path_ret;
char path_separator;
guint i;
@@ -529,10 +528,8 @@ geoip_db_get_paths(void) {
}
g_string_truncate(path_str, path_str->len-1);
- path_ret = path_str->str;
- g_string_free(path_str, FALSE);
- return path_ret;
+ return g_string_free(path_str, FALSE);
}
#else /* HAVE_GEOIP */
diff --git a/epan/oids.c b/epan/oids.c
index 2e5ec06447..2437a46a00 100644
--- a/epan/oids.c
+++ b/epan/oids.c
@@ -1219,7 +1219,6 @@ extern gchar *
oid_get_default_mib_path(void) {
#ifdef HAVE_LIBSMI
GString* path_str;
- gchar *path_ret;
char *path;
guint i;
@@ -1256,9 +1255,7 @@ oid_get_default_mib_path(void) {
g_string_append_printf(path_str,PATH_SEPARATOR "%s",smi_paths[i].name);
}
- path_ret = path_str->str;
- g_string_free(path_str, FALSE);
- return path_ret;
+ return g_string_free(path_str, FALSE);
#else /* HAVE_LIBSMI */
return g_strdup("");
#endif
diff --git a/epan/radius_dict.l b/epan/radius_dict.l
index b4600ed393..25f313afb3 100644
--- a/epan/radius_dict.l
+++ b/epan/radius_dict.l
@@ -609,8 +609,7 @@ gboolean radius_load_dictionary (radius_dictionary_t* d, gchar* dir, const gchar
if (!yyin) {
g_string_append_printf(error, "Could not open file: '%s', error: %s\n", fullpaths[include_stack_ptr], g_strerror(errno) );
g_free(fullpaths[include_stack_ptr]);
- *err_str = error->str;
- g_string_free(error,FALSE);
+ *err_str = g_string_free(error,FALSE);
return FALSE;
}
@@ -632,8 +631,7 @@ gboolean radius_load_dictionary (radius_dictionary_t* d, gchar* dir, const gchar
g_hash_table_foreach_remove(value_strings,destroy_value_strings,NULL);
if (error->len > 0) {
- *err_str = error->str;
- g_string_free(error,FALSE);
+ *err_str = g_string_free(error,FALSE);
return FALSE;
} else {
*err_str = NULL;