Convert proto_construct_match_selected_string to use wmem.
Change-Id: I7a40c0996517aa71b4ddb764ce3a6e92a55260ad Reviewed-on: https://code.wireshark.org/review/6589 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
6010d99a1f
commit
5c5b3f7d26
19
epan/proto.c
19
epan/proto.c
|
@ -7390,7 +7390,7 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
|
|||
}
|
||||
|
||||
if (str != NULL && filter != NULL) {
|
||||
*filter = ep_strdup_printf("%s == \"%s\"", hfinfo->abbrev, str);
|
||||
*filter = wmem_strdup_printf(NULL, "%s == \"%s\"", hfinfo->abbrev, str);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -7441,7 +7441,7 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
|
|||
|
||||
out = hfinfo_numeric_value_format(hfinfo, buf, number);
|
||||
|
||||
*filter = ep_strdup_printf("%s == %s", hfinfo->abbrev, out);
|
||||
*filter = wmem_strdup_printf(NULL, "%s == %s", hfinfo->abbrev, out);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -7450,7 +7450,7 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
|
|||
if (filter != NULL) {
|
||||
const char *format = hfinfo_numeric_format(hfinfo);
|
||||
|
||||
*filter = ep_strdup_printf(format,
|
||||
*filter = wmem_strdup_printf(NULL, format,
|
||||
hfinfo->abbrev,
|
||||
fvalue_get_integer64(&finfo->value));
|
||||
}
|
||||
|
@ -7458,7 +7458,7 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
|
|||
|
||||
case FT_PROTOCOL:
|
||||
if (filter != NULL)
|
||||
*filter = ep_strdup(finfo->hfinfo->abbrev);
|
||||
*filter = wmem_strdup(NULL, finfo->hfinfo->abbrev);
|
||||
break;
|
||||
|
||||
case FT_NONE:
|
||||
|
@ -7472,7 +7472,7 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
|
|||
length = finfo->length;
|
||||
if (length == 0) {
|
||||
if (filter != NULL)
|
||||
*filter = ep_strdup(finfo->hfinfo->abbrev);
|
||||
*filter = wmem_strdup(NULL, finfo->hfinfo->abbrev);
|
||||
break;
|
||||
}
|
||||
if (length < 0)
|
||||
|
@ -7514,7 +7514,7 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
|
|||
if (filter != NULL) {
|
||||
start = finfo->start;
|
||||
buf_len = 32 + length * 3;
|
||||
*filter = (char *)ep_alloc0(buf_len);
|
||||
*filter = (char *)wmem_alloc0(NULL, buf_len);
|
||||
ptr = *filter;
|
||||
|
||||
ptr += g_snprintf(ptr, (gulong) (buf_len-(ptr-*filter)),
|
||||
|
@ -7549,7 +7549,7 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
|
|||
dfilter_len = fvalue_string_repr_len(&finfo->value,
|
||||
FTREPR_DFILTER, finfo->hfinfo->display);
|
||||
dfilter_len += abbrev_len + 4 + 1;
|
||||
*filter = (char *)ep_alloc0(dfilter_len);
|
||||
*filter = (char *)wmem_alloc0(NULL, dfilter_len);
|
||||
|
||||
/* Create the string */
|
||||
g_snprintf(*filter, dfilter_len, "%s == ",
|
||||
|
@ -7585,10 +7585,13 @@ proto_can_match_selected(field_info *finfo, epan_dissect_t *edt)
|
|||
char *
|
||||
proto_construct_match_selected_string(field_info *finfo, epan_dissect_t *edt)
|
||||
{
|
||||
char *filter;
|
||||
char *filter = NULL;
|
||||
|
||||
if (!construct_match_selected_string(finfo, edt, &filter))
|
||||
{
|
||||
wmem_free(NULL, filter);
|
||||
return NULL;
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
|
||||
|
|
|
@ -2202,7 +2202,7 @@ proto_can_match_selected(field_info *finfo, struct epan_dissect *edt);
|
|||
/** Construct a "match selected" display filter string.
|
||||
@param finfo field_info
|
||||
@param edt epan dissecting
|
||||
@return the display filter string */
|
||||
@return the wmem NULL alloced display filter string. Needs to be freed with wmem_free(NULL, ...) */
|
||||
WS_DLL_PUBLIC char*
|
||||
proto_construct_match_selected_string(field_info *finfo, struct epan_dissect *edt);
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ protocolinfo_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt, const vo
|
|||
str = (char *)proto_construct_match_selected_string((field_info *)gp->pdata[i], NULL);
|
||||
if (str) {
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", str);
|
||||
wmem_free(NULL, str);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -780,7 +780,10 @@ init_error_table_row(error_equiv_table *err, const expert_info_t *expert_data)
|
|||
g_assert(PITEM_FINFO(expert_data->pitem));
|
||||
filter = proto_construct_match_selected_string(PITEM_FINFO(expert_data->pitem), NULL);
|
||||
if (filter != NULL)
|
||||
{
|
||||
procedure->fvalue_value = g_string_chunk_insert_const(err->text, filter);
|
||||
wmem_free(NULL, filter);
|
||||
}
|
||||
}
|
||||
/* Store the updated count of events */
|
||||
err->num_procs = ++old_num_procs;
|
||||
|
|
|
@ -347,6 +347,7 @@ match_selected_ptree_cb(gpointer data, MATCH_SELECTED_E action)
|
|||
filter = proto_construct_match_selected_string(cfile.finfo_selected,
|
||||
cfile.edt);
|
||||
match_selected_cb_do((GtkWidget *)g_object_get_data(G_OBJECT(data), E_DFILTER_TE_KEY), action, filter);
|
||||
wmem_free(NULL, filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,6 +376,7 @@ colorize_selected_ptree_cb(GtkWidget *w _U_, gpointer data _U_, guint8 filt_nr)
|
|||
}
|
||||
packet_list_colorize_packets();
|
||||
}
|
||||
wmem_free(NULL, filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1987,12 +1987,15 @@ void MainWindow::on_actionViewReload_triggered()
|
|||
void MainWindow::matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type)
|
||||
{
|
||||
QString field_filter;
|
||||
char* tmp_field;
|
||||
|
||||
if (packet_list_->contextMenuActive()) {
|
||||
field_filter = packet_list_->getFilterFromRowAndColumn();
|
||||
} else if (capture_file_.capFile() && capture_file_.capFile()->finfo_selected) {
|
||||
field_filter = proto_construct_match_selected_string(capture_file_.capFile()->finfo_selected,
|
||||
tmp_field = proto_construct_match_selected_string(capture_file_.capFile()->finfo_selected,
|
||||
capture_file_.capFile()->edt);
|
||||
field_filter = QString(tmp_field);
|
||||
wmem_free(NULL, tmp_field);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue