Move ep_free_all() *AFTER* packet dissection.

Use glib allocator for data_source.

Thread on wireshark-dev: http://www.wireshark.org/lists/wireshark-dev/201210/msg00116.html

svn path=/trunk/; revision=45673
This commit is contained in:
Jakub Zawadzki 2012-10-20 20:04:40 +00:00
parent b53dbea042
commit 2fd81fdaf9
3 changed files with 18 additions and 10 deletions

View File

@ -192,22 +192,22 @@ void
epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
const guint8* data, frame_data *fd, column_info *cinfo)
{
/* free all memory allocated during previous packet */
ep_free_all();
dissect_packet(edt, phdr, data, fd, cinfo);
/* free all memory allocated */
ep_free_all();
}
void
epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
const guint8* data, frame_data *fd, column_info *cinfo)
{
/* free all memory allocated during previous packet */
ep_free_all();
tap_queue_init(edt);
dissect_packet(edt, phdr, data, fd, cinfo);
tap_push_tapped_queue(edt);
/* free all memory allocated */
ep_free_all();
}
void

View File

@ -66,7 +66,7 @@ static dissector_handle_t data_handle = NULL;
*/
struct data_source {
tvbuff_t *tvb;
const char *name;
char *name;
};
void
@ -229,9 +229,9 @@ add_new_data_source(packet_info *pinfo, tvbuff_t *tvb, const char *name)
{
struct data_source *src;
src = ep_alloc(sizeof (struct data_source));
src = g_malloc(sizeof(struct data_source));
src->tvb = tvb;
src->name = name;
src->name = g_strdup(name);
pinfo->data_src = g_slist_append(pinfo->data_src, src);
}
@ -254,6 +254,14 @@ void
free_data_sources(packet_info *pinfo)
{
if (pinfo->data_src) {
GSList *l;
for (l = pinfo->data_src; l; l = l->next) {
struct data_source *src = l->data;
g_free(src->name);
g_free(src);
}
g_slist_free(pinfo->data_src);
pinfo->data_src = NULL;
}

2
file.c
View File

@ -822,7 +822,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
break;
}
TRY{
if (read_packet(cf, dfcode, &edt, cinfo,
if (read_packet(cf, dfcode, &edt, (column_info *) cinfo,
data_offset) != -1) {
newly_displayed_packets++;
}