On 07/30/14 01:30, [email protected] wrote:
Hi,

On Tue, Jul 29, 2014 at 06:47:53PM -0400, Jeff Morriss wrote:
However, I don't quite understand why for tree!=NULL but not visible,
proto_tree_add_text() returns tree. I can see this in the code, we call
TRY_TO_FAKE_THIS_ITEM(), which returns the tree itself when it's not
visible. But what sense does this make for the caller?

I think it's because while proto_trees are allowed to be NULL, we
don't want (or the API is not ready for) proto_items to be NULL.
(IOW that "return tree" quoted above is (ab)using the fact that a
proto_item is a proto_tree.)


Does this mean that this code in add_subtree_format() should be
setting *tree_item to 'tree' (instead of NULL) here:

    /* Make sure pi is initialized in case TRY_TO_FAKE_THIS_ITEM bails */
        if (tree_item != NULL)
                *tree_item = NULL;

Wouldn't be it simpler if we just remove 'tree_item' argument?
Cause I understand that after change *tree_item is always the same as return 
value?

Well, no, they'll only return the same thing if TRY_TO_FAKE_THIS_ITEM short-cuts us out, right?

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

Reply via email to