aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames-ws@darkjames.pl>2013-07-09 23:10:04 +0000
committerJakub Zawadzki <darkjames-ws@darkjames.pl>2013-07-09 23:10:04 +0000
commit83322789d1b0fd22270a866c1db1f4c5a3835e61 (patch)
tree3af8ec40c28881111e4656d56061174fc70015fc
parent882d0841ae9f9c976fd9804beadfb84f1275cc8c (diff)
tvbuff: use ep_strbuf_append_unichar()
svn path=/trunk/; revision=50477
-rw-r--r--epan/tvbuff.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 97e503a55b..f520a06d9a 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -2507,31 +2507,21 @@ tvb_get_ephemeral_string(tvbuff_t *tvb, const gint offset, const gint length)
gchar *
tvb_get_ephemeral_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guint encoding)
{
- /* Longest UTF-8 character takes 6 bytes + 1 byte for NUL, round it to 8B */
- gchar tmpbuf[8];
gunichar2 uchar;
gint i; /* Byte counter for tvbuff */
- gint tmpbuf_len;
- emem_strbuf_t *strbuf = NULL;
+ emem_strbuf_t *strbuf;
tvb_ensure_bytes_exist(tvb, offset, length);
strbuf = ep_strbuf_new(NULL);
for(i = 0; i < length; i += 2) {
-
if (encoding == ENC_BIG_ENDIAN)
uchar = tvb_get_ntohs(tvb, offset + i);
else
uchar = tvb_get_letohs(tvb, offset + i);
- tmpbuf_len = g_unichar_to_utf8(uchar, tmpbuf);
-
- /* NULL terminate the tmpbuf so ep_strbuf_append knows where
- * to stop */
- tmpbuf[tmpbuf_len] = '\0';
-
- ep_strbuf_append(strbuf, tmpbuf);
+ ep_strbuf_append_unichar(strbuf, uchar);
}
return strbuf->str;
@@ -2733,32 +2723,22 @@ tvb_get_ephemeral_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp)
gchar *
tvb_get_ephemeral_unicode_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp, const guint encoding)
{
- /* Longest UTF-8 character takes 6 bytes + 1 byte for NUL, round it to 8B */
- gchar tmpbuf[8];
gunichar2 uchar;
gint size; /* Number of UTF-16 characters */
gint i; /* Byte counter for tvbuff */
- gint tmpbuf_len;
- emem_strbuf_t *strbuf = NULL;
-
- strbuf = ep_strbuf_new(NULL);
+ emem_strbuf_t *strbuf;
size = tvb_unicode_strsize(tvb, offset);
- for(i = 0; i < size; i += 2) {
+ strbuf = ep_strbuf_new(NULL);
+ for(i = 0; i < size; i += 2) {
if (encoding == ENC_BIG_ENDIAN)
uchar = tvb_get_ntohs(tvb, offset + i);
else
uchar = tvb_get_letohs(tvb, offset + i);
- tmpbuf_len = g_unichar_to_utf8(uchar, tmpbuf);
-
- /* NULL terminate the tmpbuf so ep_strbuf_append knows where
- * to stop */
- tmpbuf[tmpbuf_len] = '\0';
-
- ep_strbuf_append(strbuf, tmpbuf);
+ ep_strbuf_append_unichar(strbuf, uchar);
}
if (lengthp)