From 252d55d80f92fa8267758fbf4faab520d2f79273 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 19 Nov 2000 08:54:37 +0000 Subject: For each column, have both a buffer into which strings for that column can be put, and a pointer to the string for the column, which might or might not point to that buffer. Add a routine "col_set_str()", which sets the string for the column to the string passed to it as an argument; it should only be handed a static string (a string constant would be ideal). It doesn't do any copying, so it's faster than "col_add_str()". Make the routines that append to columns check whether the pointer to the string for the column points to the buffer for the column and, if not, copy the string for the column to the buffer for the column so that you can append to it (so you can use "col_set_str()" and then use "col_append_str()" or "col_append_fstr()"). Convert a bunch of "col_add_str()" calls that take a string constant as an argument to "col_set_str()" calls. Convert some "col_add_fstr()" calls that take a string constant as the only argument - i.e., the format string doesn't have any "%" slots into which to put strings for subsequent arguments to "col_set_str()" calls (those calls are just like "col_add_str()" calls). Replace an END_OF_FRAME reference in a tvbuffified dissector with a "tvb_length(tvb)" call. svn path=/trunk/; revision=2670 --- packet-ddtp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'packet-ddtp.c') diff --git a/packet-ddtp.c b/packet-ddtp.c index 057c8ccfc9..3ec6eaa0f4 100644 --- a/packet-ddtp.c +++ b/packet-ddtp.c @@ -3,7 +3,7 @@ * see http://ddt.sourceforge.net/ * Olivier Abad * - * $Id: packet-ddtp.c,v 1.10 2000/08/13 14:08:08 deniel Exp $ + * $Id: packet-ddtp.c,v 1.11 2000/11/19 08:53:56 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -108,7 +108,7 @@ dissect_ddtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pinfo->current_proto = "DDTP"; if (check_col(pinfo->fd, COL_PROTOCOL)) { /* Indicate what kind of message this is. */ - col_add_str (pinfo->fd, COL_PROTOCOL, "DDTP"); + col_set_str (pinfo->fd, COL_PROTOCOL, "DDTP"); } if (tree) { ti = proto_tree_add_item(tree, proto_ddtp, tvb, 0, @@ -123,11 +123,11 @@ dissect_ddtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) switch (tvb_get_ntohl(tvb, 12)) { case DDTP_MESSAGE_ERROR : if (check_col(pinfo->fd, COL_INFO)) - col_add_str (pinfo->fd, COL_INFO, "Message Error"); + col_set_str (pinfo->fd, COL_INFO, "Message Error"); break; case DDTP_UPDATE_QUERY : if (check_col(pinfo->fd, COL_INFO)) - col_add_str (pinfo->fd, COL_INFO, "Update Query"); + col_set_str (pinfo->fd, COL_INFO, "Update Query"); proto_tree_add_item(ddtp_tree, hf_ddtp_opcode, tvb, 16, 4, FALSE); proto_tree_add_item(ddtp_tree, hf_ddtp_ipaddr, tvb, 20, 4, @@ -135,25 +135,25 @@ dissect_ddtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; case DDTP_UPDATE_REPLY : if (check_col(pinfo->fd, COL_INFO)) - col_add_str (pinfo->fd, COL_INFO, "Update Reply"); + col_set_str (pinfo->fd, COL_INFO, "Update Reply"); proto_tree_add_item(ddtp_tree, hf_ddtp_status, tvb, 16, 4, FALSE); break; case DDTP_ALIVE_QUERY : if (check_col(pinfo->fd, COL_INFO)) - col_add_str (pinfo->fd, COL_INFO, "Alive Query"); + col_set_str (pinfo->fd, COL_INFO, "Alive Query"); proto_tree_add_text(ddtp_tree, tvb, 16, 4, "Dummy : %u", tvb_get_ntohl(tvb, 16)); break; case DDTP_ALIVE_REPLY : if (check_col(pinfo->fd, COL_INFO)) - col_add_str (pinfo->fd, COL_INFO, "Alive Reply"); + col_set_str (pinfo->fd, COL_INFO, "Alive Reply"); proto_tree_add_text(ddtp_tree, tvb, 16, 4, "Dummy : %u", tvb_get_ntohl(tvb, 16)); break; default : if (check_col(pinfo->fd, COL_INFO)) - col_add_str (pinfo->fd, COL_INFO, "Unknwon type"); + col_set_str (pinfo->fd, COL_INFO, "Unknwon type"); proto_tree_add_text(ddtp_tree, tvb, 12, 4, "Unknown type : %u", tvb_get_ntohl(tvb, 12)); } -- cgit v1.2.3