aboutsummaryrefslogtreecommitdiffstats
path: root/echld/dispatcher.c
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 /echld/dispatcher.c
parent9f5e4fb7a51741a286ce5bc92a6f335ed58587a2 (diff)
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 'echld/dispatcher.c')
-rw-r--r--echld/dispatcher.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/echld/dispatcher.c b/echld/dispatcher.c
index 20e59753f6..b18261b701 100644
--- a/echld/dispatcher.c
+++ b/echld/dispatcher.c
@@ -207,7 +207,6 @@ static char* intflist2json(GList* if_list, char** if_cap_err) {
if_capabilities_t *caps;
char addr_str[ADDRSTRLEN];
GString *str = g_string_new("{ what='interfaces', interfaces={ \n");
- char* s;
for (if_entry = g_list_first(if_list); if_entry != NULL;
if_entry = g_list_next(if_entry)) {
@@ -315,9 +314,7 @@ static char* intflist2json(GList* if_list, char** if_cap_err) {
g_string_truncate(str,str->len - 2); /* the comma and return */
g_string_append(str,"}");
- s=str->str;
- g_string_free(str,FALSE);
- return s;
+ return g_string_free(str,FALSE);
}
static char* intf_list = NULL;
@@ -382,7 +379,6 @@ static char* param_get_version(char** err _U_) {
static char* param_get_capture_types(char** err _U_) {
GString* str = g_string_new("");
- char* s;
int i;
for (i = 0; i < WTAP_NUM_FILE_TYPES_SUBTYPES; i++) {
@@ -392,9 +388,7 @@ static char* param_get_capture_types(char** err _U_) {
}
}
- s = str->str;
- g_string_free(str,FALSE);
- return s;
+ return g_string_free(str,FALSE);
}
static echld_bool_t param_set_add_hosts_file(char* val, char** err) {