diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2003-12-02 10:23:18 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2003-12-02 10:23:18 +0000 |
commit | bfaca0cab6888f39623afd5d8f75a8fb39f24ec0 (patch) | |
tree | e97c89575023b23bbe32c74bd70d98f8908f6cc0 /epan/tvbuff.h | |
parent | 266b5a4b2e6ad843a05d4f4c6a1f6ebf19949a06 (diff) | |
download | wireshark-bfaca0cab6888f39623afd5d8f75a8fb39f24ec0.tar.gz |
Move the definition of the tvbuff_t structure and friends to tvbuff.h
so that we can change tvb_get_ds_tvb() into a macro.
This function was a single line assignment and was called a lot.
This made tethereal ~2.5% faster in one testcase I use.
svn path=/trunk/; revision=9141
Diffstat (limited to 'epan/tvbuff.h')
-rw-r--r-- | epan/tvbuff.h | 74 |
1 files changed, 68 insertions, 6 deletions
diff --git a/epan/tvbuff.h b/epan/tvbuff.h index 156de931fa..2758f136c8 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -9,7 +9,7 @@ * the data of a backing tvbuff, or can be a composite of * other tvbuffs. * - * $Id: tvbuff.h,v 1.34 2003/08/27 15:23:03 gram Exp $ + * $Id: tvbuff.h,v 1.35 2003/12/02 10:23:18 sahlberg Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu> * @@ -38,10 +38,6 @@ #include <glib.h> #include "exceptions.h" -typedef struct tvbuff tvbuff_t; - -typedef void (*tvbuff_free_cb_t)(void*); - /* The different types of tvbuff's */ typedef enum { TVBUFF_REAL_DATA, @@ -49,6 +45,71 @@ typedef enum { TVBUFF_COMPOSITE } tvbuff_type; +typedef struct { + /* The backing tvbuff_t */ + struct tvbuff *tvb; + + /* The offset/length of 'tvb' to which I'm privy */ + guint offset; + guint length; + +} tvb_backing_t; + +typedef struct { + GSList *tvbs; + + /* Used for quick testing to see if this + * is the tvbuff that a COMPOSITE is + * interested in. */ + guint *start_offsets; + guint *end_offsets; + +} tvb_comp_t; + +typedef void (*tvbuff_free_cb_t)(void*); + +typedef struct tvbuff { + /* Record-keeping */ + tvbuff_type type; + gboolean initialized; + guint usage_count; + struct tvbuff *ds_tvb; /* data source top-level tvbuff */ + + /* The tvbuffs in which this tvbuff is a member + * (that is, a backing tvbuff for a TVBUFF_SUBSET + * or a member for a TVB_COMPOSITE) */ + GSList *used_in; + + /* TVBUFF_SUBSET and TVBUFF_COMPOSITE keep track + * of the other tvbuff's they use */ + union { + tvb_backing_t subset; + tvb_comp_t composite; + } tvbuffs; + + /* We're either a TVBUFF_REAL_DATA or a + * TVBUFF_SUBSET that has a backing buffer that + * has real_data != NULL, or a TVBUFF_COMPOSITE + * which has flattened its data due to a call + * to tvb_get_ptr(). + */ + guint8 *real_data; + + /* Length of virtual buffer (and/or real_data). */ + guint length; + + /* Reported length. */ + guint reported_length; + + /* Offset from beginning of first TVBUFF_REAL. */ + gint raw_offset; + + /* Func to call when actually freed */ + tvbuff_free_cb_t free_cb; +} tvbuff_t; + + + /* TVBUFF_REAL_DATA contains a guint8* that points to real data. * The data is allocated and contiguous. * @@ -433,7 +494,8 @@ extern gint tvb_memeql(tvbuff_t *tvb, gint offset, const guint8 *str, */ extern gchar *tvb_bytes_to_str(tvbuff_t *tvb, gint offset, gint len); -extern tvbuff_t *tvb_get_ds_tvb(tvbuff_t *tvb); +#define TVB_GET_DS_TVB(tvb) \ + (tvb->ds_tvb) /* Locate a sub-tvbuff within another tvbuff, starting at position * 'haystack_offset'. Returns the index of the beginning of 'needle' within |