diff options
author | Michael Mann <mmann78@netscape.net> | 2012-08-25 00:39:17 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2012-08-25 00:39:17 +0000 |
commit | c7cbfac88d2870796e1afd009cef389ba596796a (patch) | |
tree | c486a109151a4d15818d59e77c8e0c869bd0e1b4 /epan/dissectors/packet-xdmcp.c | |
parent | 95d14df10a0c2a076e7c033f3095a826842d3741 (diff) |
cleanup some unnecessary g_malloc calls
svn path=/trunk/; revision=44662
Diffstat (limited to 'epan/dissectors/packet-xdmcp.c')
-rw-r--r-- | epan/dissectors/packet-xdmcp.c | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/epan/dissectors/packet-xdmcp.c b/epan/dissectors/packet-xdmcp.c index 69008047ce..4fc7a975de 100644 --- a/epan/dissectors/packet-xdmcp.c +++ b/epan/dissectors/packet-xdmcp.c @@ -96,31 +96,15 @@ static gint ett_xdmcp_authorization_names = -1; static gint ett_xdmcp_connections = -1; static gint ett_xdmcp_connection = -1; -/* Copied from packet-x11.c */ -static void stringCopy(char *dest, const char *source, int length) -{ - guchar c; - while(length--) { - c = *source++; - if (!isgraph(c) && c != ' ') c = '.'; - *dest++ = c; - } - *dest++ = '\0'; -} - static gint xdmcp_add_string(proto_tree *tree, gint hf, tvbuff_t *tvb, gint offset) { - const guint8 *p; char *str; guint len; len = tvb_get_ntohs(tvb, offset); - p = tvb_get_ptr(tvb, offset+2, len); - str = g_malloc(len+1); - stringCopy(str, (gchar*)p, len); + str = tvb_get_ephemeral_string(tvb, offset+2, len); proto_tree_add_string(tree, hf, tvb, offset, len+2, str); - g_free(str); return len+2; } @@ -128,16 +112,12 @@ static gint xdmcp_add_string(proto_tree *tree, gint hf, static gint xdmcp_add_text(proto_tree *tree, const char *text, tvbuff_t *tvb, gint offset) { - const guint8 *p; char *str; guint len; len = tvb_get_ntohs(tvb, offset); - p = tvb_get_ptr(tvb, offset+2, len); - str = g_malloc(len+1); - stringCopy(str, (gchar*)p, len); + str = tvb_get_ephemeral_string(tvb, offset+2, len); proto_tree_add_text(tree, tvb, offset, len+2, "%s: %s", text, str); - g_free(str); return len+2; } |