Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Equivalency between APIs

Date: Tue, 26 Aug 2014 13:27:35 -0400 (EDT)
Yes it's true assuming "ti_channel" isn't otherwise used.
 
 
 
-----Original Message-----
From: Juan Jose Martin Carrascosa <juanjo@xxxxxxx>
To: Developer support list for Wireshark <wireshark-dev@xxxxxxxxxxxxx>
Sent: Tue, Aug 26, 2014 11:32 am
Subject: Re: [Wireshark-dev] Equivalency between APIs

Thanks for your reply. Regarding the last comment, just to double check since I am not very experienced on this... it would be like:

 channel_tree = proto_tree_add_subtree_format(rtps_parameter_tree, tvb, off, 0,
           ett_rtps_locator_filter_channel, NULL, "Channel[%u]", ch);

True?

- Juanjo


On Tue, Aug 26, 2014 at 5:19 PM, <mmann78@xxxxxxxxxxxx> wrote:
You are correct.  proto_tree_add_subtree is for no printf-style arguments, proto_tree_add_subtree_format is for when you need printf-style arguments for your subtree.
 
One thing to check (if you're compiler doesn't do it for you because somebody's will) is that you may no longer need the proto_item* passed into proto_tree_add_subtree[_format].
 
Many dissectors had
ti = proto_tree_add_text(....)
subtree = proto_item_add_subtree(ti, ett) 
 
and never referenced ti again.  So when that's converted to proto_tree_add_subtree, you can just pass NULL in for the proto_item* parameter.
 
 
 
 
-----Original Message-----
From: Juan Jose Martin Carrascosa <juanjo@xxxxxxx>
To: Developer support list for Wireshark <wireshark-dev@xxxxxxxxxxxxx>
Sent: Tue, Aug 26, 2014 9:43 am
Subject: [Wireshark-dev] Equivalency between APIs

Hi all, 

I need to remove the proto_tree_add_text calls, and I wanted to know if this is equivalent:

Before:

        ti_channel = proto_tree_add_text(rtps_parameter_tree, tvb, off, 0, "Channel[%u]", ch);
        channel_tree = proto_item_add_subtree(ti_channel, ett_rtps_locator_filter_channel);

Now:
        channel_tree = proto_tree_add_subtree_format(rtps_parameter_tree, tvb, off, 0,
           ett_rtps_locator_filter_channel, &ti_channel, "Channel[%u]", ch);


Thanks!
Juanjo
___________________________________________________________________________
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

___________________________________________________________________________
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

___________________________________________________________________________
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