Ethereal-dev: Re: [Ethereal-dev] README.developer - if (tree)

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Devin Heitmueller <dheitmueller@xxxxxxxxxxx>
Date: Tue, 16 Dec 2003 22:22:34 -0000
How about this -- can we replace the function proto_tree_add_X() with a
macro that checks to see if the first argument is non-null?  This would
eliminate the need for the developer to add the "if (tree)" before every
call.  We would get the benefits of not having to do the stack loading,
but also not have to clutter the code with the if statements.


On Tue, 2003-12-16 at 16:01, Guy Harris wrote:
> On Dec 16, 2003, at 12:51 PM, Biot Olivier wrote:
> 
> > If I remember correctly, one does not need to write an
> > if (tree) { } around all proto_XXX_add_YYY() as this is
> > already dealt with in the proto_XXX_add_YYY() functions,
> > right?
> 
> One does not need to do so.  However, if you have a large chunk of 
> dissection code that only puts stuff into the protocol tree, and 
> doesn't get any data or update any offsets necessary for calling 
> subdissectors (which is the case for just about everything in a 
> dissector that has no subdissectors, and may be true for stuff even in 
> a dissector that has subdissectors), it might be less expensive to skip 
> all that work rather than calling the "proto_XXX_add_YYY" functions - 
> especially if it's a "proto_XXX_add_YYY_format" function and there's a 
> significant amount of work involved in preparing the arguments to use 
> with the format string.
> 
> _______________________________________________
> Ethereal-dev mailing list
> Ethereal-dev@xxxxxxxxxxxx
> http://www.ethereal.com/mailman/listinfo/ethereal-dev
-- 
Devin Heitmueller
Senior Software Engineer
Netilla Networks Inc.