summaryrefslogtreecommitdiff
path: root/epan/wslua/wslua_tvb.c
diff options
context:
space:
mode:
authorHadriel Kaplan <hadriel@128technology.com>2014-12-29 00:21:15 -0500
committerMichael Mann <mmann78@netscape.net>2015-01-04 21:02:38 +0000
commitfac8356610fadf488ff92c5a22e5177bb33a2511 (patch)
treeaf8a1ceec7eb91c5a6a5e6e2ac14621425125e65 /epan/wslua/wslua_tvb.c
parent5653fcedca8491829d6d6ce480e7fba13ff801d7 (diff)
downloadwireshark-fac8356610fadf488ff92c5a22e5177bb33a2511.tar.gz
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/wslua/wslua_tvb.c')
-rw-r--r--epan/wslua/wslua_tvb.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/epan/wslua/wslua_tvb.c b/epan/wslua/wslua_tvb.c
index 8d0a359050..489690ad6c 100644
--- a/epan/wslua/wslua_tvb.c
+++ b/epan/wslua/wslua_tvb.c
@@ -498,16 +498,16 @@ WSLUA_CONSTRUCTOR TvbRange_tvb (lua_State *L) {
}
WSLUA_METAMETHOD Tvb__tostring(lua_State* L) {
- /* Convert the bytes of a `Tvb` into a string, to be used for debugging purposes as '...'
- will be appended in case the string is too long. */
+ /* Convert the bytes of a `Tvb` into a string, to be used for debugging purposes, as '...'
+ will be appended if the string is too long. */
Tvb tvb = checkTvb(L,1);
- int len;
- gchar* str;
+ int len = tvb_captured_length(tvb->ws_tvb);
+ char* str = tvb_bytes_to_wmem_str(NULL,tvb->ws_tvb,0,len);
+
+ lua_pushfstring(L, "TVB(%d) : %s", len, str);
- len = tvb_captured_length(tvb->ws_tvb);
- str = wmem_strdup_printf(NULL, "TVB(%i) : %s",len,tvb_bytes_to_ep_str(tvb->ws_tvb,0,len));
- lua_pushstring(L,str);
wmem_free(NULL, str);
+
WSLUA_RETURN(1); /* The string. */
}
@@ -1554,10 +1554,11 @@ WSLUA_METHOD TvbRange_raw(lua_State* L) {
WSLUA_METAMETHOD TvbRange__tostring(lua_State* L) {
- /* Converts the `TvbRange` into a string. As the string gets truncated
+ /* Converts the `TvbRange` into a string. Since the string gets truncated,
you should use this only for debugging purposes
or if what you want is to have a truncated string in the format 67:89:AB:... */
TvbRange tvbr = checkTvbRange(L,1);
+ char* str = NULL;
if (!(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@@ -1565,8 +1566,12 @@ WSLUA_METAMETHOD TvbRange__tostring(lua_State* L) {
return 0;
}
- lua_pushstring(L,tvb_bytes_to_ep_str(tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len));
- return 1;
+ str = tvb_bytes_to_wmem_str(NULL,tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len);
+
+ lua_pushstring(L,str);
+ wmem_free(NULL, str);
+
+ WSLUA_RETURN(1); /* A Lua hex string of the first 24 binary bytes in the `TvbRange`. */
}
WSLUA_METHODS TvbRange_methods[] = {