aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2013-03-16 08:12:29 +0000
committerAnders Broman <anders.broman@ericsson.com>2013-03-16 08:12:29 +0000
commit27744ecc2d9925491e5ef8cc97e41d551efc6a2e (patch)
tree6aba5a4a5dc7c11be8982099065f85f32665f968 /epan/wslua
parent1931018a58a1ce88969cc95fac47810b8b70c1ed (diff)
From beroset:
remove C++ incompatibilities https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 svn path=/trunk/; revision=48337
Diffstat (limited to 'epan/wslua')
-rw-r--r--epan/wslua/init_wslua.c9
-rwxr-xr-xepan/wslua/make-taps.pl6
-rw-r--r--epan/wslua/wslua_dumper.c16
-rw-r--r--epan/wslua/wslua_field.c28
-rw-r--r--epan/wslua/wslua_gui.c28
-rw-r--r--epan/wslua/wslua_listener.c10
-rw-r--r--epan/wslua/wslua_pinfo.c30
-rw-r--r--epan/wslua/wslua_tree.c12
-rw-r--r--epan/wslua/wslua_tvb.c36
-rw-r--r--epan/wslua/wslua_util.c8
10 files changed, 92 insertions, 91 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c
index 046104c472..286d91bfe5 100644
--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -68,7 +68,7 @@ int dissect_lua(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data
lua_pinfo = pinfo;
lua_tvb = tvb;
- lua_tree = g_malloc(sizeof(struct _wslua_treeitem));
+ lua_tree = (struct _wslua_treeitem *)g_malloc(sizeof(struct _wslua_treeitem));
lua_tree->tree = tree;
lua_tree->item = proto_tree_add_text(tree,tvb,0,0,"lua fake item");
lua_tree->expired = FALSE;
@@ -332,12 +332,13 @@ int wslua_init(register_cb cb, gpointer client_data) {
(*cb)(RA_LUA_PLUGINS, NULL, client_data);
/* set up the logger */
- g_log_set_handler(LOG_DOMAIN_LUA, G_LOG_LEVEL_CRITICAL|
+ g_log_set_handler(LOG_DOMAIN_LUA, (GLogLevelFlags)(G_LOG_LEVEL_CRITICAL|
G_LOG_LEVEL_WARNING|
G_LOG_LEVEL_MESSAGE|
G_LOG_LEVEL_INFO|
- G_LOG_LEVEL_DEBUG,
- ops ? ops->logger : basic_logger, NULL);
+ G_LOG_LEVEL_DEBUG),
+ ops ? ops->logger : basic_logger,
+ NULL);
if (!L) {
L = luaL_newstate();
diff --git a/epan/wslua/make-taps.pl b/epan/wslua/make-taps.pl
index bac63f3cce..81e5f40004 100755
--- a/epan/wslua/make-taps.pl
+++ b/epan/wslua/make-taps.pl
@@ -41,8 +41,8 @@ my %types = %{{
'gint16' => 'lua_pushnumber(L,(lua_Number)v->%s);',
'gint32' => 'lua_pushnumber(L,(lua_Number)v->%s);',
'gboolean' => 'lua_pushboolean(L,(int)v->%s);',
- 'address' => '{ Address a = g_malloc(sizeof(address)); COPY_ADDRESS(a, &(v->%s)); pushAddress(L,a); }',
- 'address*' => '{ Address a = g_malloc(sizeof(address)); COPY_ADDRESS(a, v->%s); pushAddress(L,a); }',
+ 'address' => '{ Address a = (Address)g_malloc(sizeof(address)); COPY_ADDRESS(a, &(v->%s)); pushAddress(L,a); }',
+ 'address*' => '{ Address a = (Address)g_malloc(sizeof(address)); COPY_ADDRESS(a, v->%s); pushAddress(L,a); }',
'int' => 'lua_pushnumber(L,(lua_Number)v->%s);',
'nstime_t' => '{lua_Number t = (lua_Number) v->%s.secs; t += v->%s.nsecs * 1e-9; lua_pushnumber(L,t); }',
'nstime_t*' => '{lua_Number t = (lua_Number) v->%s->secs; t += v->%s->nsecs * 1e-9; lua_pushnumber(L,t); }',
@@ -124,7 +124,7 @@ sub dotap {
$elems{$k} = $v;
}
- my $code = "static void wslua_${tname}_to_table(lua_State* L, const void* p) { $sname* v _U_; v = (void*)p; lua_newtable(L);\n";
+ my $code = "static void wslua_${tname}_to_table(lua_State* L, const void* p) { $sname* v _U_; v = ($sname*)p; lua_newtable(L);\n";
my $doc = "Tap: $tname\n";
for my $n (sort keys %elems) {
diff --git a/epan/wslua/wslua_dumper.c b/epan/wslua/wslua_dumper.c
index 51fdab099c..0690d44421 100644
--- a/epan/wslua/wslua_dumper.c
+++ b/epan/wslua/wslua_dumper.c
@@ -64,7 +64,7 @@ WSLUA_CONSTRUCTOR PseudoHeader_none(lua_State* L) {
Creates a "no" pseudoheader.
*/
- PseudoHeader ph = g_malloc(sizeof(struct lua_pseudo_header));
+ PseudoHeader ph = (PseudoHeader)g_malloc(sizeof(struct lua_pseudo_header));
ph->type = PHDR_NONE;
ph->wph = NULL;
@@ -81,9 +81,9 @@ WSLUA_CONSTRUCTOR PseudoHeader_eth(lua_State* L) {
#define WSLUA_OPTARG_PseudoHeader_eth_FCSLEN 1 /* The fcs length */
- PseudoHeader ph = g_malloc(sizeof(struct lua_pseudo_header));
+ PseudoHeader ph = (PseudoHeader)g_malloc(sizeof(struct lua_pseudo_header));
ph->type = PHDR_ETH;
- ph->wph = g_malloc(sizeof(union wtap_pseudo_header));
+ ph->wph = (union wtap_pseudo_header *)g_malloc(sizeof(union wtap_pseudo_header));
ph->wph->eth.fcs_len = luaL_optint(L,WSLUA_OPTARG_PseudoHeader_eth_FCSLEN,-1);
pushPseudoHeader(L,ph);
@@ -103,9 +103,9 @@ WSLUA_CONSTRUCTOR PseudoHeader_atm(lua_State* L) {
#define WSLUA_OPTARG_PseudoHeader_atm_AAL5U2U 6 /* AAL5 User to User indicator */
#define WSLUA_OPTARG_PseudoHeader_atm_AAL5LEN 7 /* AAL5 Len */
- PseudoHeader ph = g_malloc(sizeof(struct lua_pseudo_header));
+ PseudoHeader ph = (PseudoHeader)g_malloc(sizeof(struct lua_pseudo_header));
ph->type = PHDR_ATM;
- ph->wph = g_malloc(sizeof(union wtap_pseudo_header));
+ ph->wph = (union wtap_pseudo_header *)g_malloc(sizeof(union wtap_pseudo_header));
ph->wph->atm.aal = luaL_optint(L,WSLUA_OPTARG_PseudoHeader_atm_AAL,5);
ph->wph->atm.vpi = luaL_optint(L,WSLUA_OPTARG_PseudoHeader_atm_VPI,1);
ph->wph->atm.vci = luaL_optint(L,WSLUA_OPTARG_PseudoHeader_atm_VCI,1);
@@ -124,9 +124,9 @@ WSLUA_CONSTRUCTOR PseudoHeader_mtp2(lua_State* L) {
#define WSLUA_OPTARG_PseudoHeader_mtp2_SENT 1 /* True if the packet is sent, False if received. */
#define WSLUA_OPTARG_PseudoHeader_mtp2_ANNEXA 2 /* True if annex A is used */
#define WSLUA_OPTARG_PseudoHeader_mtp2_LINKNUM 3 /* Link Number */
- PseudoHeader ph = g_malloc(sizeof(struct lua_pseudo_header));
+ PseudoHeader ph = (PseudoHeader)g_malloc(sizeof(struct lua_pseudo_header));
ph->type = PHDR_MTP2;
- ph->wph = g_malloc(sizeof(union wtap_pseudo_header));
+ ph->wph = (union wtap_pseudo_header *)g_malloc(sizeof(union wtap_pseudo_header));
ph->wph->mtp2.sent = luaL_optint(L,WSLUA_OPTARG_PseudoHeader_mtp2_SENT,0);
ph->wph->mtp2.annex_a_used = luaL_optint(L,WSLUA_OPTARG_PseudoHeader_mtp2_ANNEXA,0);
ph->wph->mtp2.link_number = luaL_optint(L,WSLUA_OPTARG_PseudoHeader_mtp2_LINKNUM,0);
@@ -392,7 +392,7 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
if (lua_pinfo->fd->opt_comment)
pkthdr.opt_comment = ep_strdup(lua_pinfo->fd->opt_comment);
- data = ep_tvb_memdup(tvb,0,pkthdr.caplen);
+ data = (const guchar *)ep_tvb_memdup(tvb,0,pkthdr.caplen);
if (! wtap_dump(d, &pkthdr, data, &err)) {
luaL_error(L,"error while dumping: %s",
diff --git a/epan/wslua/wslua_field.c b/epan/wslua/wslua_field.c
index 5c323874ad..98397f76c6 100644
--- a/epan/wslua/wslua_field.c
+++ b/epan/wslua/wslua_field.c
@@ -86,19 +86,19 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
lua_pushnumber(L,(lua_Number)fvalue_get_floating(&(fi->value)));
return 1;
case FT_INT64: {
- Int64 num = g_malloc(sizeof(gint64));
+ Int64 num = (Int64)g_malloc(sizeof(gint64));
*num = fvalue_get_integer64(&(fi->value));
pushInt64(L,num);
return 1;
}
case FT_UINT64: {
- UInt64 num = g_malloc(sizeof(guint64));
+ UInt64 num = (UInt64)g_malloc(sizeof(guint64));
*num = fvalue_get_integer64(&(fi->value));
pushUInt64(L,num);
return 1;
}
case FT_ETHER: {
- Address eth = g_malloc(sizeof(address));
+ Address eth = (Address)g_malloc(sizeof(address));
eth->type = AT_ETHER;
eth->len = fi->length;
eth->data = tvb_memdup(fi->ds_tvb,fi->start,fi->length);
@@ -106,7 +106,7 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
return 1;
}
case FT_IPv4:{
- Address ipv4 = g_malloc(sizeof(address));
+ Address ipv4 = (Address)g_malloc(sizeof(address));
ipv4->type = AT_IPv4;
ipv4->len = fi->length;
ipv4->data = tvb_memdup(fi->ds_tvb,fi->start,fi->length);
@@ -114,7 +114,7 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
return 1;
}
case FT_IPv6: {
- Address ipv6 = g_malloc(sizeof(address));
+ Address ipv6 = (Address)g_malloc(sizeof(address));
ipv6->type = AT_IPv6;
ipv6->len = fi->length;
ipv6->data = tvb_memdup(fi->ds_tvb,fi->start,fi->length);
@@ -122,7 +122,7 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
return 1;
}
case FT_IPXNET:{
- Address ipx = g_malloc(sizeof(address));
+ Address ipx = (Address)g_malloc(sizeof(address));
ipx->type = AT_IPX;
ipx->len = fi->length;
ipx->data = tvb_memdup(fi->ds_tvb,fi->start,fi->length);
@@ -131,7 +131,7 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
}
case FT_ABSOLUTE_TIME:
case FT_RELATIVE_TIME: {
- NSTime nstime = g_malloc(sizeof(nstime_t));
+ NSTime nstime = (NSTime)g_malloc(sizeof(nstime_t));
*nstime = *(NSTime)fvalue_get(&(fi->value));
pushNSTime(L,nstime);
return 1;
@@ -152,7 +152,7 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
case FT_PROTOCOL:
case FT_OID: {
ByteArray ba = g_byte_array_new();
- g_byte_array_append(ba, ep_tvb_memdup(fi->ds_tvb,fi->start,fi->length),fi->length);
+ g_byte_array_append(ba, (const guint8 *)ep_tvb_memdup(fi->ds_tvb,fi->start,fi->length),fi->length);
pushByteArray(L,ba);
return 1;
}
@@ -221,8 +221,8 @@ static int FieldInfo_display(lua_State* L) {
static int FieldInfo_get_range(lua_State* L) {
/* The TvbRange covering this field */
FieldInfo fi = checkFieldInfo(L,1);
- TvbRange r = ep_alloc(sizeof(struct _wslua_tvbrange));
- r->tvb = ep_alloc(sizeof(struct _wslua_tvb));
+ TvbRange r = ep_new(struct _wslua_tvbrange);
+ r->tvb = ep_new(struct _wslua_tvb);
r->tvb->ws_tvb = fi->ds_tvb;
r->offset = fi->start;
@@ -374,7 +374,7 @@ WSLUA_FUNCTION wslua_all_field_infos(lua_State* L) {
if (found) {
for (i=0; i<found->len; i++) {
- pushFieldInfo(L,g_ptr_array_index(found,i));
+ pushFieldInfo(L,(FieldInfo)g_ptr_array_index(found,i));
items_found++;
}
@@ -422,7 +422,7 @@ void lua_prime_all_fields(proto_tree* tree _U_) {
static gboolean fake_tap = FALSE;
for(i=0; i < wanted_fields->len; i++) {
- Field f = g_ptr_array_index(wanted_fields,i);
+ Field f = (Field)g_ptr_array_index(wanted_fields,i);
gchar* name = *((gchar**)f);
*f = proto_registrar_get_byname(name);
@@ -478,7 +478,7 @@ WSLUA_CONSTRUCTOR Field_new(lua_State *L) {
if (!wanted_fields)
WSLUA_ERROR(Field_get,"A Field extractor must be defined before Taps or Dissectors get called");
- f = g_malloc(sizeof(void*));
+ f = (Field)g_malloc(sizeof(void*));
*f = (header_field_info*)g_strdup(name); /* cheating */
g_ptr_array_add(wanted_fields,f);
@@ -507,7 +507,7 @@ WSLUA_METAMETHOD Field__call (lua_State* L) {
guint i;
if (found) {
for (i=0; i<found->len; i++) {
- pushFieldInfo(L,g_ptr_array_index(found,i));
+ pushFieldInfo(L,(FieldInfo)g_ptr_array_index(found,i));
items_found++;
}
}
diff --git a/epan/wslua/wslua_gui.c b/epan/wslua/wslua_gui.c
index 73925859a4..fb9bb6b64d 100644
--- a/epan/wslua/wslua_gui.c
+++ b/epan/wslua/wslua_gui.c
@@ -49,7 +49,7 @@ WSLUA_FUNCTION wslua_gui_enabled(lua_State* L) { /* Checks whether the GUI facil
}
static void lua_menu_callback(gpointer data) {
- struct _lua_menu_data* md = data;
+ struct _lua_menu_data* md = (struct _lua_menu_data *)data;
lua_State* L = md->L;
lua_settop(L,0);
@@ -89,7 +89,7 @@ WSLUA_FUNCTION wslua_register_menu(lua_State* L) { /* Register a menu item in o
const gchar* name = luaL_checkstring(L,WSLUA_ARG_register_menu_NAME);
struct _lua_menu_data* md;
gboolean retap = FALSE;
- register_stat_group_t group = (int)luaL_optnumber(L,WSLUA_OPTARG_register_menu_GROUP,REGISTER_STAT_GROUP_GENERIC);
+ register_stat_group_t group = (register_stat_group_t)luaL_optnumber(L,WSLUA_OPTARG_register_menu_GROUP,REGISTER_STAT_GROUP_GENERIC);
if ( group > REGISTER_TOOLS_GROUP_UNSORTED)
WSLUA_OPTARG_ERROR(register_menu,GROUP,"Must be a defined MENU_* (see init.lua)");
@@ -100,7 +100,7 @@ WSLUA_FUNCTION wslua_register_menu(lua_State* L) { /* Register a menu item in o
if (!lua_isfunction(L,WSLUA_ARG_register_menu_ACTION))
WSLUA_ARG_ERROR(register_menu,ACTION,"Must be a function");
- md = g_malloc(sizeof(struct _lua_menu_data));
+ md = (struct _lua_menu_data *)g_malloc(sizeof(struct _lua_menu_data));
md->L = L;
lua_pushvalue(L, 2);
@@ -131,7 +131,7 @@ static int dlg_cb_error_handler(lua_State* L) {
}
static void lua_dialog_cb(gchar** user_input, void* data) {
- struct _dlg_cb_data* dcbd = data;
+ struct _dlg_cb_data* dcbd = (struct _dlg_cb_data *)data;
int i = 0;
gchar* input;
lua_State* L = dcbd->L;
@@ -177,7 +177,7 @@ static int text_win_close_cb_error_handler(lua_State* L) {
}
static void text_win_close_cb(void* data) {
- struct _close_cb_data* cbd = data;
+ struct _close_cb_data* cbd = (struct _close_cb_data *)data;
lua_State* L = cbd->L;
if (cbd->L) { /* close function is set */
@@ -241,7 +241,7 @@ WSLUA_FUNCTION wslua_new_dialog(lua_State* L) { /* Pops up a new dialog */
}
- dcbd = g_malloc(sizeof(struct _dlg_cb_data));
+ dcbd = (struct _dlg_cb_data *)g_malloc(sizeof(struct _dlg_cb_data));
dcbd->L = L;
lua_remove(L,1);
@@ -255,7 +255,7 @@ WSLUA_FUNCTION wslua_new_dialog(lua_State* L) { /* Pops up a new dialog */
top -= 2;
for (i = 1; i <= top; i++) {
- gchar* label = (void*)luaL_checkstring(L,i);
+ gchar* label = (gchar *)luaL_checkstring(L,i);
/* XXX leaks labels on error */
if (! label)
@@ -280,7 +280,7 @@ WSLUA_CLASS_DEFINE(ProgDlg,NOP,NOP); /* Manages a progress bar dialog. */
WSLUA_CONSTRUCTOR ProgDlg_new(lua_State* L) { /* Creates a new TextWindow. */
#define WSLUA_OPTARG_ProgDlg_new_TITLE 2 /* Title of the new window, defaults to "Progress". */
#define WSLUA_OPTARG_ProgDlg_new_TASK 3 /* Current task, defaults to "". */
- ProgDlg pd = g_malloc(sizeof(struct _wslua_progdlg));
+ ProgDlg pd = (ProgDlg)g_malloc(sizeof(struct _wslua_progdlg));
pd->title = g_strdup(luaL_optstring(L,WSLUA_OPTARG_ProgDlg_new_TITLE,"Progress"));
pd->task = g_strdup(luaL_optstring(L,WSLUA_OPTARG_ProgDlg_new_TASK,""));
pd->stopped = FALSE;
@@ -429,11 +429,11 @@ WSLUA_CONSTRUCTOR TextWindow_new(lua_State* L) { /* Creates a new TextWindow. */
}
title = luaL_optstring(L,WSLUA_OPTARG_TextWindow_new_TITLE,"Untitled Window");
- tw = g_malloc(sizeof(struct _wslua_tw));
+ tw = (struct _wslua_tw *)g_malloc(sizeof(struct _wslua_tw));
tw->expired = FALSE;
tw->ws_tw = ops->new_text_window(title);
- default_cbd = g_malloc(sizeof(struct _close_cb_data));
+ default_cbd = (struct _close_cb_data *)g_malloc(sizeof(struct _close_cb_data));
default_cbd->L = NULL;
default_cbd->func_ref = 0;
@@ -464,7 +464,7 @@ WSLUA_METHOD TextWindow_set_atclose(lua_State* L) { /* Set the function that wil
if (! lua_isfunction(L,2))
WSLUA_ARG_ERROR(TextWindow_at_close,ACTION,"Must be a function");
- cbd = g_malloc(sizeof(struct _close_cb_data));
+ cbd = (struct _close_cb_data *)g_malloc(sizeof(struct _close_cb_data));
cbd->L = L;
cbd->func_ref = luaL_ref(L, LUA_REGISTRYINDEX);
@@ -626,7 +626,7 @@ typedef struct _wslua_bt_cb_t {
} wslua_bt_cb_t;
static gboolean wslua_button_callback(funnel_text_window_t* ws_tw, void* data) {
- wslua_bt_cb_t* cbd = data;
+ wslua_bt_cb_t* cbd = (wslua_bt_cb_t *)data;
lua_State* L = cbd->L;
(void) ws_tw; /* ws_tw is unused since we need wslua_tw_ref and it is stored in cbd */
@@ -676,8 +676,8 @@ WSLUA_METHOD TextWindow_add_button(lua_State* L) {
lua_settop(L,3);
if (ops->add_button) {
- fbt = g_malloc(sizeof(funnel_bt_t));
- cbd = g_malloc(sizeof(wslua_bt_cb_t));
+ fbt = (funnel_bt_t *)g_malloc(sizeof(funnel_bt_t));
+ cbd = (wslua_bt_cb_t *)g_malloc(sizeof(wslua_bt_cb_t));
fbt->tw = tw->ws_tw;
fbt->func = wslua_button_callback;
diff --git a/epan/wslua/wslua_listener.c b/epan/wslua/wslua_listener.c
index 5657983153..065c2fec4c 100644
--- a/epan/wslua/wslua_listener.c
+++ b/epan/wslua/wslua_listener.c
@@ -82,7 +82,7 @@ static int tap_packet_cb_error_handler(lua_State* L) {
static int lua_tap_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const void *data) {
- Listener tap = tapdata;
+ Listener tap = (Listener)tapdata;
int retval = 0;
if (tap->packet_ref == LUA_NOREF) return 0;
@@ -103,7 +103,7 @@ static int lua_tap_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt
lua_pinfo = pinfo;
lua_tvb = edt->tvb;
- lua_tree = g_malloc(sizeof(struct _wslua_treeitem));
+ lua_tree = (struct _wslua_treeitem *)g_malloc(sizeof(struct _wslua_treeitem));
lua_tree->tree = edt->tree;
lua_tree->item = NULL;
lua_tree->expired = FALSE;
@@ -139,7 +139,7 @@ static int tap_reset_cb_error_handler(lua_State* L) {
}
static void lua_tap_reset(void *tapdata) {
- Listener tap = tapdata;
+ Listener tap = (Listener)tapdata;
if (tap->init_ref == LUA_NOREF) return;
@@ -162,7 +162,7 @@ static void lua_tap_reset(void *tapdata) {
}
static void lua_tap_draw(void *tapdata) {
- Listener tap = tapdata;
+ Listener tap = (Listener)tapdata;
const gchar* error;
if (tap->draw_ref == LUA_NOREF) return;
@@ -196,7 +196,7 @@ WSLUA_CONSTRUCTOR Listener_new(lua_State* L) {
Listener tap;
GString* error;
- tap = g_malloc(sizeof(struct _wslua_tap));
+ tap = (Listener)g_malloc(sizeof(struct _wslua_tap));
tap->name = g_strdup(tap_type);
tap->filter = filter ? g_strdup(filter) : NULL;
diff --git a/epan/wslua/wslua_pinfo.c b/epan/wslua/wslua_pinfo.c
index 477b26ce63..6bea086517 100644
--- a/epan/wslua/wslua_pinfo.c
+++ b/epan/wslua/wslua_pinfo.c
@@ -57,7 +57,7 @@ CLEAR_OUTSTANDING(PrivateTable,expired, TRUE)
Pinfo* push_Pinfo(lua_State* L, packet_info* ws_pinfo) {
Pinfo pinfo = NULL;
if (ws_pinfo) {
- pinfo = g_malloc(sizeof(struct _wslua_pinfo));
+ pinfo = (Pinfo)g_malloc(sizeof(struct _wslua_pinfo));
pinfo->ws_pinfo = ws_pinfo;
pinfo->expired = FALSE;
g_ptr_array_add(outstanding_Pinfo,pinfo);
@@ -76,7 +76,7 @@ WSLUA_CONSTRUCTOR NSTime_new(lua_State *L) {
/* Creates a new NSTime object */
#define WSLUA_OPTARG_NSTime_new_SECONDS 1 /* Seconds */
#define WSLUA_OPTARG_NSTime_new_NSECONDS 2 /* Nano seconds */
- NSTime nstime = g_malloc(sizeof(nstime_t));
+ NSTime nstime = (NSTime)g_malloc(sizeof(nstime_t));
if (!nstime) return 0;
@@ -100,7 +100,7 @@ WSLUA_METAMETHOD NSTime__tostring(lua_State* L) {
WSLUA_METAMETHOD NSTime__add(lua_State* L) { /* Calculates the sum of two NSTimes */
NSTime time1 = checkNSTime(L,1);
NSTime time2 = checkNSTime(L,2);
- NSTime time3 = g_malloc (sizeof (nstime_t));
+ NSTime time3 = (NSTime)g_malloc (sizeof (nstime_t));
nstime_sum (time3, time1, time2);
pushNSTime (L, time3);
@@ -111,7 +111,7 @@ WSLUA_METAMETHOD NSTime__add(lua_State* L) { /* Calculates the sum of two NSTime
WSLUA_METAMETHOD NSTime__sub(lua_State* L) { /* Calculates the diff of two NSTimes */
NSTime time1 = checkNSTime(L,1);
NSTime time2 = checkNSTime(L,2);
- NSTime time3 = g_malloc (sizeof (nstime_t));
+ NSTime time3 = (NSTime)g_malloc (sizeof (nstime_t));
nstime_delta (time3, time1, time2);
pushNSTime (L, time3);
@@ -121,7 +121,7 @@ WSLUA_METAMETHOD NSTime__sub(lua_State* L) { /* Calculates the diff of two NSTim
WSLUA_METAMETHOD NSTime__unm(lua_State* L) { /* Calculates the negative NSTime */
NSTime time1 = checkNSTime(L,1);
- NSTime time2 = g_malloc (sizeof (nstime_t));
+ NSTime time2 = (NSTime)g_malloc (sizeof (nstime_t));
nstime_set_zero (time2);
nstime_subtract (time2, time1);
@@ -311,8 +311,8 @@ WSLUA_CONSTRUCTOR Address_ip(lua_State* L) {
/* Creates an Address Object representing an IP address. */
#define WSLUA_ARG_Address_ip_HOSTNAME 1 /* The address or name of the IP host. */
- Address addr = g_malloc(sizeof(address));
- guint32* ip_addr = g_malloc(sizeof(guint32));
+ Address addr = (Address)g_malloc(sizeof(address));
+ guint32* ip_addr = (guint32 *)g_malloc(sizeof(guint32));
const gchar* name = luaL_checkstring(L,WSLUA_ARG_Address_ip_HOSTNAME);
if (! get_host_ipaddr(name, (guint32*)ip_addr)) {
@@ -781,7 +781,7 @@ WSLUA_METAMETHOD Columns_index(lua_State *L) {
const char* colname = luaL_checkstring(L,2);
if (!cols) {
- Column c = g_malloc(sizeof(struct _wslua_col_info));
+ Column c = (Column)g_malloc(sizeof(struct _wslua_col_info));
c->cinfo = NULL;
c->col = col_name_to_id(colname);
c->expired = FALSE;
@@ -800,7 +800,7 @@ WSLUA_METAMETHOD Columns_index(lua_State *L) {
for(cn = colnames; cn->name; cn++) {
if( g_str_equal(cn->name,colname) ) {
- Column c = g_malloc(sizeof(struct _wslua_col_info));
+ Column c = (Column)g_malloc(sizeof(struct _wslua_col_info));
c->cinfo = cols->cinfo;
c->col = col_name_to_id(colname);
c->expired = FALSE;
@@ -856,7 +856,7 @@ WSLUA_METAMETHOD PrivateTable__tostring(lua_State* L) {
keys = g_hash_table_get_keys (priv->table);
key = g_list_first (keys);
while (key) {
- key_string = g_string_append (key_string, key->data);
+ key_string = g_string_append (key_string, (const gchar *)key->data);
key = g_list_next (key);
if (key) {
key_string = g_string_append_c (key_string, ',');
@@ -884,7 +884,7 @@ static int PrivateTable__index(lua_State* L) {
return 0;
}
- string = g_hash_table_lookup (priv->table, (gpointer) name);
+ string = (const gchar *)g_hash_table_lookup (priv->table, (gpointer) name);
if (string) {
lua_pushstring(L, string);
@@ -1075,7 +1075,7 @@ static int Pinfo_columns(lua_State *L) {
return 0;
}
- cols = g_malloc(sizeof(struct _wslua_cols));
+ cols = (Columns)g_malloc(sizeof(struct _wslua_cols));
cols->cinfo = pinfo->ws_pinfo->cinfo;
cols->expired = FALSE;
@@ -1108,7 +1108,7 @@ static int Pinfo_private(lua_State *L) {
is_allocated = TRUE;
}
- priv = g_malloc(sizeof(struct _wslua_private_table));
+ priv = (PrivateTable)g_malloc(sizeof(struct _wslua_private_table));
priv->table = pinfo->ws_pinfo->private_table;
priv->is_allocated = is_allocated;
priv->expired = FALSE;
@@ -1239,7 +1239,7 @@ static int Pinfo_hi(lua_State *L) {
return 0;
}
- addr = g_malloc(sizeof(address));
+ addr = (Address)g_malloc(sizeof(address));
if (CMP_ADDRESS(&(pinfo->ws_pinfo->src), &(pinfo->ws_pinfo->dst) ) >= 0) {
COPY_ADDRESS(addr, &(pinfo->ws_pinfo->src));
} else {
@@ -1260,7 +1260,7 @@ static int Pinfo_lo(lua_State *L) {
return 0;
}
- addr = g_malloc(sizeof(address));
+ addr = (Address)g_malloc(sizeof(address));
if (CMP_ADDRESS(&(pinfo->ws_pinfo->src), &(pinfo->ws_pinfo->dst) ) < 0) {
COPY_ADDRESS(addr, &(pinfo->ws_pinfo->src));
} else {
diff --git a/epan/wslua/wslua_tree.c b/epan/wslua/wslua_tree.c
index 565cddc3ba..870c955147 100644
--- a/epan/wslua/wslua_tree.c
+++ b/epan/wslua/wslua_tree.c
@@ -84,8 +84,8 @@ WSLUA_METHOD TreeItem_add_packet_field(lua_State *L) {
tvbr = shiftTvbRange(L,1);
if (!tvbr) {
/* No TvbRange specified */
- tvbr = ep_alloc(sizeof(struct _wslua_tvbrange));
- tvbr->tvb = ep_alloc(sizeof(struct _wslua_tvb));
+ tvbr = ep_new(struct _wslua_tvbrange);
+ tvbr->tvb = ep_new(struct _wslua_tvb);
tvbr->tvb->ws_tvb = lua_tvb;
tvbr->offset = 0;
tvbr->len = 0;
@@ -115,7 +115,7 @@ WSLUA_METHOD TreeItem_add_packet_field(lua_State *L) {
lua_remove(L,1);
}
- tree_item = g_malloc(sizeof(struct _wslua_treeitem));
+ tree_item = (TreeItem)g_malloc(sizeof(struct _wslua_treeitem));
tree_item->item = item;
tree_item->tree = proto_item_add_subtree(item,ett > 0 ? ett : wslua_ett);
tree_item->expired = FALSE;
@@ -158,8 +158,8 @@ static int TreeItem_add_item_any(lua_State *L, gboolean little_endian) {
tvbr = shiftTvbRange(L,1);
if (!tvbr) {
- tvbr = ep_alloc(sizeof(struct _wslua_tvbrange));
- tvbr->tvb = ep_alloc(sizeof(struct _wslua_tvb));
+ tvbr = ep_new(struct _wslua_tvbrange);
+ tvbr->tvb = ep_new(struct _wslua_tvb);
tvbr->tvb->ws_tvb = lua_tvb;
tvbr->offset = 0;
tvbr->len = 0;
@@ -255,7 +255,7 @@ static int TreeItem_add_item_any(lua_State *L, gboolean little_endian) {
lua_remove(L,1);
}
- tree_item = g_malloc(sizeof(struct _wslua_treeitem));
+ tree_item = (TreeItem)g_malloc(sizeof(struct _wslua_treeitem));
tree_item->item = item;
tree_item->tree = proto_item_add_subtree(item,ett > 0 ? ett : wslua_ett);
tree_item->expired = FALSE;
diff --git a/epan/wslua/wslua_tvb.c b/epan/wslua/wslua_tvb.c
index 431b323444..dc8d821ed3 100644
--- a/epan/wslua/wslua_tvb.c
+++ b/epan/wslua/wslua_tvb.c
@@ -151,7 +151,7 @@ WSLUA_METHOD ByteArray_set_size(lua_State* L) {
if (ba->len >= (guint)siz) { /* truncate */
g_byte_array_set_size(ba,siz);
} else { /* fill */
- padding = g_malloc0(sizeof(guint8)*(siz - ba->len));
+ padding = (guint8 *)g_malloc0(sizeof(guint8)*(siz - ba->len));
g_byte_array_append(ba,padding,siz - ba->len);
g_free(padding);
}
@@ -387,7 +387,7 @@ void clear_outstanding_TvbRange(void) {
Tvb* push_Tvb(lua_State* L, tvbuff_t* ws_tvb) {
- Tvb tvb = g_malloc(sizeof(struct _wslua_tvb));
+ Tvb tvb = (Tvb)g_malloc(sizeof(struct _wslua_tvb));
tvb->ws_tvb = ws_tvb;
tvb->expired = FALSE;
tvb->need_free = FALSE;
@@ -415,9 +415,9 @@ WSLUA_CONSTRUCTOR ByteArray_tvb (lua_State *L) {
return 0;
}
- data = g_memdup(ba->data, ba->len);
+ data = (guint8 *)g_memdup(ba->data, ba->len);
- tvb = g_malloc(sizeof(struct _wslua_tvb));
+ tvb = (Tvb)g_malloc(sizeof(struct _wslua_tvb));
tvb->ws_tvb = tvb_new_real_data(data, ba->len,ba->len);
tvb->expired = FALSE;
tvb->need_free = TRUE;
@@ -442,7 +442,7 @@ WSLUA_CONSTRUCTOR TvbRange_tvb (lua_State *L) {
}
if (tvb_offset_exists(tvbr->tvb->ws_tvb, tvbr->offset + tvbr->len -1 )) {
- tvb = g_malloc(sizeof(struct _wslua_tvb));
+ tvb = (Tvb)g_malloc(sizeof(struct _wslua_tvb));
tvb->expired = FALSE;
tvb->need_free = FALSE;
tvb->ws_tvb = tvb_new_subset(tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len, tvbr->len);
@@ -587,8 +587,8 @@ static TvbRange new_TvbRange(lua_State* L, tvbuff_t* ws_tvb, int offset, int len
return NULL;
}
- tvbr = g_malloc(sizeof(struct _wslua_tvbrange));
- tvbr->tvb = g_malloc(sizeof(struct _wslua_tvb));
+ tvbr = (TvbRange)g_malloc(sizeof(struct _wslua_tvbrange));
+ tvbr->tvb = (Tvb)g_malloc(sizeof(struct _wslua_tvb));
tvbr->tvb->ws_tvb = ws_tvb;
tvbr->tvb->expired = FALSE;
tvbr->tvb->need_free = FALSE;
@@ -735,7 +735,7 @@ WSLUA_METHOD TvbRange_uint64(lua_State* L) {
case 6:
case 7:
case 8: {
- UInt64 num = g_malloc(sizeof(guint64));
+ UInt64 num = (UInt64)g_malloc(sizeof(guint64));
*num = tvb_get_ntoh64(tvbr->tvb->ws_tvb,tvbr->offset);
pushUInt64(L,num);
WSLUA_RETURN(1);
@@ -767,7 +767,7 @@ WSLUA_METHOD TvbRange_le_uint64(lua_State* L) {
case 6:
case 7:
case 8: {
- UInt64 num = g_malloc(sizeof(guint64));
+ UInt64 num = (UInt64)g_malloc(sizeof(guint64));
*num = tvb_get_letoh64(tvbr->tvb->ws_tvb,tvbr->offset);
pushUInt64(L,num);
WSLUA_RETURN(1);
@@ -862,7 +862,7 @@ WSLUA_METHOD TvbRange_int64(lua_State* L) {
case 6:
case 7:
case 8: {
- Int64 num = g_malloc(sizeof(gint64));
+ Int64 num = (Int64)g_malloc(sizeof(gint64));
*num = (gint64)tvb_get_ntoh64(tvbr->tvb->ws_tvb,tvbr->offset);
pushInt64(L,num);
WSLUA_RETURN(1);
@@ -894,7 +894,7 @@ WSLUA_METHOD TvbRange_le_int64(lua_State* L) {
case 6:
case 7:
case 8: {
- Int64 num = g_malloc(sizeof(gint64));
+ Int64 num = (Int64)g_malloc(sizeof(gint64));
*num = (gint64)tvb_get_letoh64(tvbr->tvb->ws_tvb,tvbr->offset);
pushInt64(L,num);
WSLUA_RETURN(1);
@@ -966,9 +966,9 @@ WSLUA_METHOD TvbRange_ipv4(lua_State* L) {
if (tvbr->len != 4)
WSLUA_ERROR(TvbRange_ipv4,"The range must be 4 octets long");
- addr = g_malloc(sizeof(address));
+ addr = (address *)g_malloc(sizeof(address));
- ip_addr = g_malloc(sizeof(guint32));
+ ip_addr = (guint32 *)g_malloc(sizeof(guint32));
*ip_addr = tvb_get_ipv4(tvbr->tvb->ws_tvb,tvbr->offset);
SET_ADDRESS(addr, AT_IPv4, 4, ip_addr);
@@ -992,9 +992,9 @@ WSLUA_METHOD TvbRange_le_ipv4(lua_State* L) {
if (tvbr->len != 4)
WSLUA_ERROR(TvbRange_ipv4,"The range must be 4 octets long");
- addr = g_malloc(sizeof(address));
+ addr = (address *)g_malloc(sizeof(address));
- ip_addr = g_malloc(sizeof(guint32));
+ ip_addr = (guint32 *)g_malloc(sizeof(guint32));
*ip_addr = tvb_get_ipv4(tvbr->tvb->ws_tvb,tvbr->offset);
*((guint32 *)ip_addr) = GUINT32_SWAP_LE_BE(*((guint32 *)ip_addr));
@@ -1021,7 +1021,7 @@ WSLUA_METHOD TvbRange_ether(lua_State* L) {
addr = g_new(address,1);
- buff = tvb_memdup(tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len);
+ buff = (guint8 *)tvb_memdup(tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len);
SET_ADDRESS(addr, AT_ETHER, 6, buff);
pushAddress(L,addr);
@@ -1185,7 +1185,7 @@ WSLUA_METHOD TvbRange_bytes(lua_State* L) {
}
ba = g_byte_array_new();
- g_byte_array_append(ba,ep_tvb_memdup(tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len),tvbr->len);
+ g_byte_array_append(ba,(const guint8 *)ep_tvb_memdup(tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len),tvbr->len);
pushByteArray(L,ba);
@@ -1222,7 +1222,7 @@ WSLUA_METHOD TvbRange_bitfield(lua_State* L) {
lua_pushnumber(L,tvb_get_bits32(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
return 1;
} else if (len <= 64) {
- UInt64 num = g_malloc(sizeof(guint64));
+ UInt64 num = (UInt64)g_malloc(sizeof(guint64));
*num = tvb_get_bits64(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE);
pushUInt64(L,num);
WSLUA_RETURN(1); /* The bitfield value */
diff --git a/epan/wslua/wslua_util.c b/epan/wslua/wslua_util.c
index 21f5af3323..575277b5e7 100644
--- a/epan/wslua/wslua_util.c
+++ b/epan/wslua/wslua_util.c
@@ -292,11 +292,11 @@ WSLUA_CONSTRUCTOR Dir_open(lua_State* L) {
WSLUA_ARG_ERROR(Dir_open,PATHNAME, "must be a directory");
}
- dir = g_malloc(sizeof(struct _wslua_dir));
+ dir = (Dir)g_malloc(sizeof(struct _wslua_dir));
dir->dir = OPENDIR_OP(dirname_clean);
g_free(dirname_clean);
dir->ext = extension ? g_strdup(extension) : NULL;
- dir->dummy = g_malloc(sizeof(GError *));
+ dir->dummy = (GError **)g_malloc(sizeof(GError *));
*(dir->dummy) = NULL;
if (dir->dir == NULL) {
@@ -414,7 +414,7 @@ static int statcmd_init_cb_error_handler(lua_State* L _U_) {
}
static void statcmd_init(const char *optarg, void* userdata) {
- statcmd_t* sc = userdata;
+ statcmd_t* sc = (statcmd_t *)userdata;
lua_State* L = sc->L;
lua_settop(L,0);
@@ -444,7 +444,7 @@ WSLUA_FUNCTION wslua_register_stat_cmd_arg(lua_State* L) {
#define WSLUA_ARG_register_stat_cmd_arg_ARGUMENT 1 /* Argument */
#define WSLUA_OPTARG_register_stat_cmd_arg_ACTION 2 /* Action */
const char* arg = luaL_checkstring(L,WSLUA_ARG_register_stat_cmd_arg_ARGUMENT);
- statcmd_t* sc = g_malloc0(sizeof(statcmd_t)); /* XXX leaked */
+ statcmd_t* sc = (statcmd_t *)g_malloc0(sizeof(statcmd_t)); /* XXX leaked */
sc->L = L;
lua_pushvalue(L, WSLUA_OPTARG_register_stat_cmd_arg_ACTION);