Wireshark mailing list archives

Re: Equivalency between APIs


From: mmann78 () netscape net
Date: Tue, 26 Aug 2014 11:19:18 -0400 (EDT)



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 () rti com>
To: Developer support list for Wireshark <wireshark-dev () wireshark org>
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 () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

 

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: