On Thu, 2005-04-14 at 13:37, [EMAIL PROTECTED] wrote: > Again and again, I have to fill in someTable_get_first_data_point() > and someTable_get_next_data_point() and -- always afraid of duplicate > code -- I don't want similar logic in both.
Always wise. > I can almost always do something like: > *my_loop_context = (void*)0; > return someTable_get_next_data_point(...); <Grin> I've documented precisely this trick in That Bloody Book :-) The only thing to be aware of is that the "get_next_data_point" routine will typically receive a loop_context handle for "this row" (i.e. the one currently being considered), so will need to return a loop_context handle for the following one. But the data_context handle must still refer to the current row. So the get_next routine may well include something like: index = (int)*loop_context; : *data_context = &(my_array[ index ]); index++; *loop_context = index; i.e. moving from one row to the next between setting up the two context parameters. Not too difficult, as long as you're clear about how things are used. > The clarity and simplicity of the code appeals to my sense > of aesthetics and parsimony. Occam would be pleased. Thanks. <curtseys> Why, thank you, kind Sir. Dave (on behalf of the whole Net-SNMP development community!) ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders