aboutsummaryrefslogtreecommitdiffstats
path: root/epan/ftypes/ftypes.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-11-25 19:25:31 +0000
committerGuy Harris <guy@alum.mit.edu>2003-11-25 19:25:31 +0000
commit06f204843e227a7d6747ac02b0d27861b78ef6e6 (patch)
treee8439cc6f881f872bfb69f8687bdb7d19f902203 /epan/ftypes/ftypes.c
parent3dd28656ba5eff8c113732e0451ced6133aee97a (diff)
Individual fvalue_t's aren't individually allocated with "g_malloc()",
so they can't be freed with "g_free()"; keep a list of the chunks of "fvalue_t"s, which are whare are allocated with "g_malloc()", so we can free them all. svn path=/trunk/; revision=9090
Diffstat (limited to 'epan/ftypes/ftypes.c')
-rw-r--r--epan/ftypes/ftypes.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c
index c924c44d8d..31237d2b36 100644
--- a/epan/ftypes/ftypes.c
+++ b/epan/ftypes/ftypes.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftypes.c,v 1.13 2003/11/25 13:20:36 sahlberg Exp $
+ * $Id: ftypes.c,v 1.14 2003/11/25 19:25:31 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -33,6 +33,15 @@ static ftype_t* type_list[FT_NUM_TYPES];
/* Space for quickly allocating/de-allocating fvalue_t's */
fvalue_t *fvalue_free_list=NULL;
+/* Chunk of fvalue_t values */
+#define FVALUE_TS_PER_CHUNK 200
+typedef struct _fvalue_chunk_t {
+ struct _fvalue_chunk_t *next;
+ fvalue_t fvalues[FVALUE_TS_PER_CHUNK];
+} fvalue_chunk_t;
+
+static fvalue_chunk_t *fvalue_chunk_list;
+
/* These are the ftype registration functions that need to be called.
* This list and the initialization function could be produced
* via a script, like the dissector registration, but there's so few
@@ -63,12 +72,13 @@ ftypes_initialize(void)
void
ftypes_cleanup(void)
{
- while (fvalue_free_list) {
- fvalue_t *tmpfv;
- tmpfv=fvalue_free_list->ptr_u.next;
- g_free(fvalue_free_list);
- fvalue_free_list=tmpfv;
+ while (fvalue_chunk_list) {
+ fvalue_chunk_t *tmpchunk;
+ tmpchunk=fvalue_chunk_list->next;
+ g_free(fvalue_chunk_list);
+ fvalue_chunk_list=tmpchunk;
}
+ fvalue_free_list=NULL;
}
@@ -207,11 +217,13 @@ fvalue_new(ftenum_t ftype)
if(!fvalue_free_list){
int i;
- fvalue_t *pfv;
- pfv=g_malloc(200*sizeof(fvalue_t));
- for(i=0;i<200;i++){
+ fvalue_chunk_t *chunk;
+ chunk=g_malloc(sizeof(fvalue_chunk_t));
+ chunk->next=fvalue_chunk_list;
+ fvalue_chunk_list=chunk;
+ for(i=0;i<FVALUE_TS_PER_CHUNK;i++){
fvalue_t *tmpfv;
- tmpfv=&pfv[i];
+ tmpfv=&chunk->fvalues[i];
tmpfv->ptr_u.next=fvalue_free_list;
fvalue_free_list=tmpfv;
}