Wireshark-dev: Re: [Wireshark-dev] [Wireshark-users] bit operations aremissingfrom lua bindings

From: Bálint Réczey <balint.reczey@xxxxxxxxxxxx>
Date: Mon, 8 Jun 2009 23:26:03 +0200
Hi,

I forgot to add the __gc.
Feel free to add the __gc or change the userdata to contain uint itself.
I can't do it myself because I'm on holiday, far from my development machine.

Regards,
Balint


-----Original Message-----
From: wireshark-dev-bounces@xxxxxxxxxxxxx on behalf of Sam Roberts
Sent: Fri 6/5/2009 13:37
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] [Wireshark-users] bit operations aremissingfrom lua bindings?
 
On Fri, Jun 5, 2009 at 11:14 AM, Sam Roberts <vieuxtech@xxxxxxxxx> wrote:
> 2009/6/5 Stig Bjørlykke <stig@xxxxxxxxxxxxx>:
>> On Fri, Jun 5, 2009 at 1:23 PM, Anders Broman
>> <anders.broman@xxxxxxxxxxxx> wrote:
>>> Couldn't: tvb_get_bits8(), tvb_get_bits16(), tvb_get_bits32(), tvb_get_bits64()
>>> Be used instead?

Add this for up to 64 bit support, for completion:

+    } else if (len <= 64) {
+        UInt64 num = g_malloc(sizeof(guint64));
+        *num = tvb_get_bits64(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos,
len, FALSE);
+        pushUInt64(L,num);
+        return 1;

Btw, I don't understand why the UInt64 userdata encapsulates a pointer
to a UInt64 instead of the uint itself. It makes it a bit harder to
use (you need the g_malloc()).

Also, the UInt64s are leaking memory. I guess the idea is a uint64
userdata can have a reference to memory it doesn't own,
which is why it doesn't define __gc to g_free() the memory?

Sam
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe

<<winmail.dat>>