manolito: use tvb_get_string_enc() for the field name

There's no need to build a string by reading byte-by-byte.

Change-Id: I23223ec1188acbd2591817d66cc8f15d4eb25427
Reviewed-on: https://code.wireshark.org/review/15486
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
This commit is contained in:
Martin Kaiser 2016-05-16 19:28:54 +02:00
parent 55fdbd5346
commit 102b216a01
1 changed files with 2 additions and 7 deletions

View File

@ -101,13 +101,14 @@ dissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* diss
guint8 dtype; /* data-type */
guint8 length; /* length */
int start; /* field starting location */
char field_name_str[3]; /* printable name */
guint8 *field_name_str;
const char *longname; /* human-friendly field name */
start = offset;
/* 2-byte field name */
field_name = tvb_get_ntohs(tvb, offset);
field_name_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 2, ENC_ASCII);
offset += 2;
/* Identify the packet based on existing fields */
@ -159,12 +160,6 @@ dissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* diss
length = tvb_get_guint8(tvb, offset);
offset++;
/* convert the 16-bit integer field name to a string */
/* XXX: changed this to use g_htons */
field_name_str[0] = g_htons(field_name) & 0x00ff;
field_name_str[1] = (g_htons(field_name) & 0xff00) >> 8;
field_name_str[2] = 0;
if (dtype == MANOLITO_STRING)
{
guint8 *str;