Wireshark-dev: Re: [Wireshark-dev] [Wireshark-users] bit operations are missingfrom lua binding

From: Sam Roberts <vieuxtech@xxxxxxxxx>
Date: Fri, 5 Jun 2009 13:37:05 -0700
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