aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-12-04 06:37:46 +0000
committerGuy Harris <guy@alum.mit.edu>2000-12-04 06:37:46 +0000
commita3fa5541a8d6ba69e1cd2ddf3116caeede8ea9b8 (patch)
treead3872d55456285223445a507a512713230c4c65 /epan
parent35bf0b2abc3c00a68752f3982f950184147160e4 (diff)
Add a "col_clear()" routine, to clear a column; it appears (and it
doesn't just seem to be a profiling artifact) that, at least on FreeBSD 3.4, it's significantly more efficient to clear out a column by stuffing a '\0' into the first byte of the column data than to do so by copying a null string (I guess when copying one byte, the fixed overhead of the procedure call and of "strcpy()" is significant). Have the TCP dissector set the Protocol column, and clear the Info column, before doing anything that might cause an exception to be thrown, so that if we *do* get an exception thrown, the frame at least shows up as TCP. Instead of, in the TCP dissector, constructing a string and then stuffing it into the Info column, just append to the Info column, which avoids one string copy. Pass a "frame_data" pointer to dissectors for TCP and IP (and PPP) options, so they can use it to append to the Info column. svn path=/trunk/; revision=2744
Diffstat (limited to 'epan')
-rw-r--r--epan/packet.c20
-rw-r--r--epan/packet.h3
2 files changed, 21 insertions, 2 deletions
diff --git a/epan/packet.c b/epan/packet.c
index e3691c908e..27e0ce7c52 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.10 2000/12/03 22:32:10 guy Exp $
+ * $Id: packet.c,v 1.11 2000/12/04 06:37:46 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -538,6 +538,24 @@ check_col(frame_data *fd, gint el) {
return FALSE;
}
+/* Use this to clear out a column, especially if you're going to be
+ appending to it later; at least on some platforms, it's more
+ efficient than using "col_add_str()" with a null string, and
+ more efficient than "col_set_str()" with a null string if you
+ later append to it, as the later append will cause a string
+ copy to be done. */
+void
+col_clear(frame_data *fd, gint el) {
+ int i;
+
+ for (i = 0; i < fd->cinfo->num_cols; i++) {
+ if (fd->cinfo->fmt_matx[i][el]) {
+ fd->cinfo->col_buf[i][0] = 0;
+ fd->cinfo->col_data[i] = fd->cinfo->col_buf[i];
+ }
+ }
+}
+
/* Use this if "str" points to something that will stay around (and thus
needn't be copied). */
void
diff --git a/epan/packet.h b/epan/packet.h
index 679bfdc65b..745b4a3cdf 100644
--- a/epan/packet.h
+++ b/epan/packet.h
@@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
- * $Id: packet.h,v 1.13 2000/12/03 22:53:09 guy Exp $
+ * $Id: packet.h,v 1.14 2000/12/04 06:37:46 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -291,6 +291,7 @@ const char *decode_numeric_bitfield(guint32 val, guint32 mask, int width,
void col_set_writable(frame_data *fd, gboolean writable);
gint check_col(frame_data *, gint);
+void col_clear(frame_data *, gint);
void col_set_str(frame_data *, gint, gchar *);
#if __GNUC__ == 2
void col_add_fstr(frame_data *, gint, gchar *, ...)