col_cleanup() is undoing the allocations that col_init() does, so it's

freeing the allocated array of pointers, not what the pointers ported
to, so it should free col_data.  Note that it does that, and put it
after col_init() in the source file and header file.

Put in a comment explaining the MSVC bug that we're working around with
the casts.

svn path=/trunk/; revision=45393
This commit is contained in:
Guy Harris 2012-10-08 17:04:37 +00:00
parent 7c5f2ec024
commit 9d4d1a5794
2 changed files with 36 additions and 25 deletions

View File

@ -43,25 +43,6 @@
#include <epan/strutil.h>
#include <epan/epan.h>
/* Cleanup all the data structures for constructing column data */
void
col_cleanup(column_info *cinfo)
{
g_free(cinfo->col_fmt);
g_free(cinfo->fmt_matx);
g_free(cinfo->col_first);
g_free(cinfo->col_last);
g_free(cinfo->col_title);
g_free(cinfo->col_custom_field);
g_free(cinfo->col_custom_occurrence);
g_free(cinfo->col_custom_field_id);
g_free(cinfo->col_custom_dfilter);
g_free(cinfo->col_buf);
g_free(cinfo->col_fence);
g_free((gchar **)cinfo->col_expr.col_expr);
g_free(cinfo->col_expr.col_expr_val);
}
/* Allocate all the data structures for constructing column data, given
the number of columns. */
void
@ -91,6 +72,35 @@ col_setup(column_info *cinfo, const gint num_cols)
}
}
/* Cleanup all the data structures for constructing column data; undoes
the allocations that col_setup() does. */
void
col_cleanup(column_info *cinfo)
{
g_free(cinfo->col_fmt);
g_free(cinfo->fmt_matx);
g_free(cinfo->col_first);
g_free(cinfo->col_last);
g_free(cinfo->col_title);
g_free(cinfo->col_custom_field);
g_free(cinfo->col_custom_occurrence);
g_free(cinfo->col_custom_field_id);
g_free(cinfo->col_custom_dfilter);
/*
* XXX - MSVC doesn't correctly handle the "const" qualifier; it thinks
* "const XXX **" means "pointer to const pointer to XXX", i.e. that
* it's a pointer to something that's "const"ant, not "pointer to
* pointer to const XXX", i.e. that it's a pointer to a pointer to
* something that's "const"ant. Cast its bogus complaints away.
*/
g_free((gchar **)cinfo->col_data);
g_free(cinfo->col_buf);
g_free(cinfo->col_fence);
/* XXX - see above */
g_free((gchar **)cinfo->col_expr.col_expr);
g_free(cinfo->col_expr.col_expr_val);
}
/* Initialize the data structures for constructing column data. */
void
col_init(column_info *cinfo)

View File

@ -39,12 +39,6 @@ extern "C" {
* Helper routines for column utility structures and routines.
*/
/** Cleanup all the data structures for constructing column data
*
* Internal, don't use this in dissectors!
*/
extern void col_cleanup(column_info *cinfo);
/** Allocate all the data structures for constructing column data, given
* the number of columns.
*
@ -52,6 +46,13 @@ extern void col_cleanup(column_info *cinfo);
*/
extern void col_setup(column_info *cinfo, const gint num_cols);
/** Cleanup all the data structures for constructing column data;
* undoes the alocations that col_setup() does.
*
* Internal, don't use this in dissectors!
*/
extern void col_cleanup(column_info *cinfo);
/** Initialize the data structures for constructing column data.
*
* Internal, don't use this in dissectors!