aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2007-10-09 18:58:34 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2007-10-09 18:58:34 +0000
commitaaec1d956fd48e349bba4f1a08f6c8582c737747 (patch)
treee726f52e539c895946c65e1ef390dcccaab2c3f1
parentd32b29abd9ec069f35bf944666881cdd8f434bc8 (diff)
Replace a (small) for loop with a memset(). Don't memset() the entire sctp_info.tvb array--it contains 2k pointers (8k or 16k of memory)--each time we start dissecting a frame. This speeds up loading a capture file full of SCTP packets by 6-8%.
svn path=/trunk/; revision=23118
-rw-r--r--epan/dissectors/packet-sctp.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index eb9e7c77eb..e7c965cb1f 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -3619,7 +3619,6 @@ static void
dissect_sctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
guint16 source_port, destination_port;
- guint number_of_ppid;
/* Extract the common header */
source_port = tvb_get_ntohs(tvb, SOURCE_PORT_OFFSET);
@@ -3638,11 +3637,21 @@ dissect_sctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO, "");
- /* is this done automatically ? */
- for(number_of_ppid = 0; number_of_ppid < MAX_NUMBER_OF_PPIDS; number_of_ppid++)
- pinfo->ppid[number_of_ppid] = 0;
+ memset(&pinfo->ppid, 0, sizeof(pinfo->ppid));
- memset(&sctp_info, 0, sizeof(struct _sctp_info));
+ /* The tvb array in struct _sctp_info is huge: currently 2k pointers.
+ * We know (by the value of 'number_of_tvbs') which of these entries have
+ * been used, so don't memset() the array. This saves us from zeroing out
+ * 8k (4-byte pointers) or 16k (8-byte pointers) of memory every time we
+ * dissect a packet (saving quite a bit of time!).
+ */
+ sctp_info.incomplete = 0;
+ sctp_info.adler32_calculated = 0;
+ sctp_info.adler32_correct = 0;
+ sctp_info.crc32c_calculated = 0;
+ sctp_info.crc32c_correct = 0;
+ sctp_info.vtag_reflected = 0;
+ sctp_info.number_of_tvbs = 0;
sctp_info.verification_tag = tvb_get_ntohl(tvb, VERIFICATION_TAG_OFFSET);
sctp_info.sport = pinfo->srcport;