On Fri, Jan 7, 2011 at 6:44 PM, Wes Hardaker <
[email protected]> wrote:

> >>>>> On Thu, 6 Jan 2011 18:44:04 +0100, Bart Van Assche <
> [email protected]> said:
>
> BVA> Having to set a flag before every call of
> netsnmp_register_table_iterator()
> BVA> is tedious and error-prone.
>
> Having to remember which function call to use with a simple 2 suffix or
> not suffix seems error prone and subject to memory bloat :-P
>
> BVA> Another alternative is to remove netsnmp_register_table_iterator() and
> to
> BVA> rename netsnmp_register_table_iterator2() into
> BVA> netsnmp_register_table_iterator(), but doing so would break backwards
> BVA> compatibility.
>
> I'd argue the requirement to own the pointer is probably sometimes good
> one way and sometimes not.  Hence the flag.
>
> The third alternative is to provide a macro, which removes the code
> bloat in the library and still allows you to have a separate function if
> you're unwilling to add the line of code above the register call.
>
> [and we're arguing about "coding taste" here, so it's important to
> realize neither of us is "wrong".  [or we both are depending on your
> point of view ;-) ]]
>
>  #define netsnmp_register_table_iterator2(x,y)                 \
>    do {                                                        \
>       y->flags |= NETSNMP_TABLE_ITERATOR_OWNS_INFO_PTR;        \
>       netsnmp_register_table_iterator(x,y);                    \
>    } while(0);
>
> I really dislike having one function be a near mirror of another because
> it means not only does the size of the executable increase but it leaves
> two places to maintain code.  We've had many cases in the past where
> changes were made to one function to fix bugs that were forgotten for a
> parallel function..


See also r19859.

Bart.
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to