Wireshark-dev: Re: [Wireshark-dev] Dynamically allocated field array
From: "Kukosa, Tomas" <tomas.kukosa@xxxxxxxxxxx>
Date: Wed, 28 Nov 2007 22:41:27 +0100
It is not a problem when you call realloc only few times. 
It only slowed down startup when realloc was called for each fiels but I have it already fixed it.
 
Tomas

________________________________

Od: wireshark-dev-bounces@xxxxxxxxxxxxx za uživatele Valery Sigalov
Odesláno: st 28.11.2007 22:21
Komu: 'Developer support list for Wireshark'
Předmět: Re: [Wireshark-dev] Dynamically allocated field array



Hi,

Thank you, I will do it. I will also think about better solution. For example, I can write the number of fields in tpncp.dat file and perform the memory allocation only once instead of using realloc. 

 

Thank you,

Valery.

 

 

________________________________

From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Kukosa, Tomas
Sent: Wednesday, November 28, 2007 11:03 PM
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] Dynamically allocated field array

 

I have already made some changes in memory allocation. Please update your source.

If it is possible to call proto_register_field_array() only once, please try it.

 

It is not critical for 0.99.7.

 

Thanks,

  Tomas

 

________________________________

Od: wireshark-dev-bounces@xxxxxxxxxxxxx za uživatele Valery Sigalov
Odesláno: st 28.11.2007 21:47
Komu: 'Developer support list for Wireshark'
Předmět: Re: [Wireshark-dev] Dynamically allocated field array

Hi,
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,
Valery.


-----Original Message-----
From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] 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

Hi,

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

Thanx,
Jaap

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
Wireshark-dev@xxxxxxxxxxxxx
http://www.wireshark.org/mailman/listinfo/wireshark-dev
_______________________________________________
Wireshark-dev mailing list
Wireshark-dev@xxxxxxxxxxxxx
http://www.wireshark.org/mailman/listinfo/wireshark-dev

<<winmail.dat>>