Use the LSAB_ALLOC and SLAB_FREE macros to allocate/free fvalue_t data
svn path=/trunk/; revision=9140
This commit is contained in:
parent
917c9da95e
commit
266b5a4b2e
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Id: ftypes.c,v 1.14 2003/11/25 19:25:31 guy Exp $
|
* $Id: ftypes.c,v 1.15 2003/12/02 09:47:23 sahlberg Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@ethereal.com>
|
* By Gerald Combs <gerald@ethereal.com>
|
||||||
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <ftypes-int.h>
|
#include <ftypes-int.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include "../slab.h"
|
||||||
|
|
||||||
/* Keep track of ftype_t's via their ftenum number */
|
/* Keep track of ftype_t's via their ftenum number */
|
||||||
static ftype_t* type_list[FT_NUM_TYPES];
|
static ftype_t* type_list[FT_NUM_TYPES];
|
||||||
|
@ -33,15 +34,6 @@ static ftype_t* type_list[FT_NUM_TYPES];
|
||||||
/* Space for quickly allocating/de-allocating fvalue_t's */
|
/* Space for quickly allocating/de-allocating fvalue_t's */
|
||||||
fvalue_t *fvalue_free_list=NULL;
|
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.
|
/* These are the ftype registration functions that need to be called.
|
||||||
* This list and the initialization function could be produced
|
* This list and the initialization function could be produced
|
||||||
* via a script, like the dissector registration, but there's so few
|
* via a script, like the dissector registration, but there's so few
|
||||||
|
@ -69,20 +61,6 @@ ftypes_initialize(void)
|
||||||
ftype_register_tvbuff();
|
ftype_register_tvbuff();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ftypes_cleanup(void)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Each ftype_t is registered via this function */
|
/* Each ftype_t is registered via this function */
|
||||||
void
|
void
|
||||||
ftype_register(enum ftenum ftype, ftype_t *ft)
|
ftype_register(enum ftenum ftype, ftype_t *ft)
|
||||||
|
@ -215,21 +193,7 @@ fvalue_new(ftenum_t ftype)
|
||||||
ftype_t *ft;
|
ftype_t *ft;
|
||||||
FvalueNewFunc new_value;
|
FvalueNewFunc new_value;
|
||||||
|
|
||||||
if(!fvalue_free_list){
|
SLAB_ALLOC(fv, fv->ptr_u.next, fvalue_free_list);
|
||||||
int 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=&chunk->fvalues[i];
|
|
||||||
tmpfv->ptr_u.next=fvalue_free_list;
|
|
||||||
fvalue_free_list=tmpfv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fv=fvalue_free_list;
|
|
||||||
fvalue_free_list=fv->ptr_u.next;
|
|
||||||
|
|
||||||
FTYPE_LOOKUP(ftype, ft);
|
FTYPE_LOOKUP(ftype, ft);
|
||||||
fv->ptr_u.ftype = ft;
|
fv->ptr_u.ftype = ft;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* ftypes.h
|
/* ftypes.h
|
||||||
* Definitions for field types
|
* Definitions for field types
|
||||||
*
|
*
|
||||||
* $Id: ftypes.h,v 1.21 2003/11/25 13:20:36 sahlberg Exp $
|
* $Id: ftypes.h,v 1.22 2003/12/02 09:47:23 sahlberg Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@ethereal.com>
|
* By Gerald Combs <gerald@ethereal.com>
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
#define FTYPES_H
|
#define FTYPES_H
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include "../slab.h"
|
||||||
|
|
||||||
/* field types */
|
/* field types */
|
||||||
enum ftenum {
|
enum ftenum {
|
||||||
|
@ -78,11 +78,6 @@ typedef enum ftrepr ftrepr_t;
|
||||||
void
|
void
|
||||||
ftypes_initialize(void);
|
ftypes_initialize(void);
|
||||||
|
|
||||||
/* Cleanup the ftypes subsystem. Called once. */
|
|
||||||
void
|
|
||||||
ftypes_cleanup(void);
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------------- FTYPE ----------------- */
|
/* ---------------- FTYPE ----------------- */
|
||||||
|
|
||||||
/* Return a string representing the name of the type */
|
/* Return a string representing the name of the type */
|
||||||
|
@ -218,13 +213,12 @@ fvalue_new(ftenum_t ftype);
|
||||||
extern fvalue_t *fvalue_free_list;
|
extern fvalue_t *fvalue_free_list;
|
||||||
#define FVALUE_FREE(fv) \
|
#define FVALUE_FREE(fv) \
|
||||||
{ \
|
{ \
|
||||||
FvalueFreeFunc free_value; \
|
register FvalueFreeFunc free_value; \
|
||||||
free_value = fv->ptr_u.ftype->free_value; \
|
free_value = fv->ptr_u.ftype->free_value; \
|
||||||
if (free_value) { \
|
if (free_value) { \
|
||||||
free_value(fv); \
|
free_value(fv); \
|
||||||
} \
|
} \
|
||||||
fv->ptr_u.next=fvalue_free_list; \
|
SLAB_FREE(fv, fv->ptr_u.next, fvalue_free_list);\
|
||||||
fvalue_free_list=fv; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* proto.c
|
/* proto.c
|
||||||
* Routines for protocol tree
|
* Routines for protocol tree
|
||||||
*
|
*
|
||||||
* $Id: proto.c,v 1.117 2003/12/02 09:11:15 sahlberg Exp $
|
* $Id: proto.c,v 1.118 2003/12/02 09:47:22 sahlberg Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@ethereal.com>
|
* By Gerald Combs <gerald@ethereal.com>
|
||||||
|
@ -291,8 +291,6 @@ proto_cleanup(void)
|
||||||
if (tree_is_expanded != NULL)
|
if (tree_is_expanded != NULL)
|
||||||
g_free(tree_is_expanded);
|
g_free(tree_is_expanded);
|
||||||
|
|
||||||
/* Cleanup the ftype subsystem */
|
|
||||||
ftypes_cleanup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* frees the resources that the dissection a proto_tree uses */
|
/* frees the resources that the dissection a proto_tree uses */
|
||||||
|
|
Loading…
Reference in New Issue