aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua/wslua_field.c
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2015-11-26 04:44:52 +0000
committerJoão Valverde <j@v6e.pt>2016-02-07 23:22:30 +0000
commit13ec77a9fc3af3b0b502820d0b55796c89997896 (patch)
treec5f5f72f090efd5471cf95095b00e13efa407959 /epan/wslua/wslua_field.c
parentd762a895ab570680e4e72142a348ad2b07c97d4f (diff)
Add free_address_wmem() and other extensions to address API
Try to improve 'address' API (to be easier/safer) and also avoid some constness warnings by not overloading the 'data' pointer to store malloc'ed buffers (use private pointer for that instead). Change-Id: I7456516b12c67620ceadac447907c12f5905bd49 Reviewed-on: https://code.wireshark.org/review/13463 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'epan/wslua/wslua_field.c')
-rw-r--r--epan/wslua/wslua_field.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/epan/wslua/wslua_field.c b/epan/wslua/wslua_field.c
index fc1a46f62a..0bb3e26774 100644
--- a/epan/wslua/wslua_field.c
+++ b/epan/wslua/wslua_field.c
@@ -124,41 +124,31 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
}
case FT_ETHER: {
Address eth = (Address)g_malloc(sizeof(address));
- eth->type = AT_ETHER;
- eth->len = fi->ws_fi->length;
- eth->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length);
+ alloc_address_tvb(NULL,eth,AT_ETHER,fi->ws_fi->length,fi->ws_fi->ds_tvb,fi->ws_fi->start);
pushAddress(L,eth);
return 1;
}
case FT_IPv4:{
Address ipv4 = (Address)g_malloc(sizeof(address));
- ipv4->type = AT_IPv4;
- ipv4->len = fi->ws_fi->length;
- ipv4->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length);
+ alloc_address_tvb(NULL,ipv4,AT_IPv4,fi->ws_fi->length,fi->ws_fi->ds_tvb,fi->ws_fi->start);
pushAddress(L,ipv4);
return 1;
}
case FT_IPv6: {
Address ipv6 = (Address)g_malloc(sizeof(address));
- ipv6->type = AT_IPv6;
- ipv6->len = fi->ws_fi->length;
- ipv6->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length);
+ alloc_address_tvb(NULL,ipv6,AT_IPv6,fi->ws_fi->length,fi->ws_fi->ds_tvb,fi->ws_fi->start);
pushAddress(L,ipv6);
return 1;
}
case FT_FCWWN: {
Address fcwwn = (Address)g_malloc(sizeof(address));
- fcwwn->type = AT_FCWWN;
- fcwwn->len = fi->ws_fi->length;
- fcwwn->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length);
+ alloc_address_tvb(NULL,fcwwn,AT_FCWWN,fi->ws_fi->length,fi->ws_fi->ds_tvb,fi->ws_fi->start);
pushAddress(L,fcwwn);
return 1;
}
case FT_IPXNET:{
Address ipx = (Address)g_malloc(sizeof(address));
- ipx->type = AT_IPX;
- ipx->len = fi->ws_fi->length;
- ipx->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length);
+ alloc_address_tvb(NULL,ipx,AT_IPX,fi->ws_fi->length,fi->ws_fi->ds_tvb,fi->ws_fi->start);
pushAddress(L,ipx);
return 1;
}