Wireshark-dev: Re: [Wireshark-dev] Dynamically allocated field array
From: Valery Sigalov <[email protected]>
Date: Wed, 28 Nov 2007 22:47:21 +0200
I agree it looks somewhat awkward. The TPNCP is constantly changing, so the fields are allocated dynamically by reading the tpncp.dat file at application startup. I replaced all the memory management functions with glib's analogs before submitting the patch, but I missed these two somehow, sorry. This code was written a long time ago and, as far as I remember, I had some problems passing dynamically allocated array to proto_register_field_array function, so I registered the fields one-by-one. Do you see the better solution? I will be glad to implement it. Meanwhile I will replace realloc and memcpy with glib's analogs. Is it critical for 0.99.7 release?

Thank you,

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jaap Keuter
Sent: Wednesday, November 28, 2007 8:09 PM
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] Dynamically allocated field array


Yeah, and I though we're using glib functions for memory management. All
this realloc and memcpy look ugly.


Kukosa, Tomas wrote:
> The packet-tpncp.c has dynamically allocated fields array and register
> them one by one:
>     /*
>      * The function proto_register_field_array can not work with dynamic
> arrays,
>      * so passing dynamic array elements one-by-one in the loop.
>      */
>     for(index = 0; index < hf_size; index++) {
>         proto_register_field_array(proto_tpncp, &hf[index], 1);
>     }
> Is it really necessary?
> Why proto_register_field_array(proto_tpncp, hf, hf_size); can not be used?
> I have probably missed something.
> Tomas

Wireshark-dev mailing list
[email protected]