Wireshark-dev: Re: [Wireshark-dev] Dynamically allocated field array
From: "Luis EG Ontanon" <luis.ontanon@xxxxxxxxx>
Date: Wed, 28 Nov 2007 23:29:02 +0100
why don't you use a GArray?

http://library.gnome.org/devel/glib/2.14/glib-Arrays.html

you can take a look on how radius and diameter do that, it is far better.

Luis


On Nov 28, 2007 10:57 PM, Valery Sigalov <Valery.Sigalov@xxxxxxxxxxxxxx> wrote:
>
>
>
>
> Hi,
>
> Great, thank you! I received your changes. Sorry for inconvenience. I will
> check the proto_register_field_array issue.
>
>
>
> Thank you,
>
> Valery.
>
>
>
>
>
>  ________________________________
>
>
> From: wireshark-dev-bounces@xxxxxxxxxxxxx
> [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Kukosa, Tomas
>  Sent: Wednesday, November 28, 2007 11:41 PM
>
>
>  To: Developer support list for Wireshark
>  Subject: Re: [Wireshark-dev] Dynamically allocated field array
>
>
>
>
>
>
>
> 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
> _______________________________________________
> Wireshark-dev mailing list
> Wireshark-dev@xxxxxxxxxxxxx
> http://www.wireshark.org/mailman/listinfo/wireshark-dev
>
>



-- 
This information is top security. When you have read it, destroy yourself.
-- Marshall McLuhan