diff options
author | Hadriel Kaplan <hadriel@128technology.com> | 2014-12-29 00:21:15 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-01-04 21:02:38 +0000 |
commit | fac8356610fadf488ff92c5a22e5177bb33a2511 (patch) | |
tree | af8a1ceec7eb91c5a6a5e6e2ac14621425125e65 /epan/to_str.c | |
parent | 5653fcedca8491829d6d6ce480e7fba13ff801d7 (diff) |
Make all Lua code use wmem not emem
Changed all remaining code in wslua that was using emem, to use wmem or
simpler methods.
Bug: 9927
Change-Id: I3d19a770e0fd77d996bdb6b61a76a722cc2bcd55
Reviewed-on: https://code.wireshark.org/review/6109
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/to_str.c')
-rw-r--r-- | epan/to_str.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/epan/to_str.c b/epan/to_str.c index c12e58b3f3..69d741ecff 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -252,6 +252,33 @@ bytes_to_ep_str(const guint8 *bd, int bd_len) return cur; } +char * +bytes_to_str(wmem_allocator_t *allocator, const guint8 *bd, int bd_len) +{ + gchar *cur; + gchar *cur_ptr; + int truncated = 0; + + if (!bd) + REPORT_DISSECTOR_BUG("Null pointer passed to bytes_to_str()"); + + cur=(gchar *)wmem_alloc(allocator, MAX_BYTE_STR_LEN+3+1); + if (bd_len <= 0) { cur[0] = '\0'; return cur; } + + if (bd_len > MAX_BYTE_STR_LEN/2) { /* bd_len > 24 */ + truncated = 1; + bd_len = MAX_BYTE_STR_LEN/2; + } + + cur_ptr = bytes_to_hexstr(cur, bd, bd_len); /* max MAX_BYTE_STR_LEN bytes */ + + if (truncated) + cur_ptr = g_stpcpy(cur_ptr, "..."); /* 3 bytes */ + + *cur_ptr = '\0'; /* 1 byte */ + return cur; +} + /* Turn an array of bytes into a string showing the bytes in hex with * punct as a bytes separator. */ |