[ldns-users] Strange comment

Alexander E. Patrakov patrakov at gmail.com
Fri Apr 2 09:01:53 UTC 2010


Hello,

I am trying to use ldns-1.6.4. However, I have a little problem with
documentation.

In ldns/rbtree.h line 46, just before the definition of ldns_rbnode_t,
there is a comment:

/**
 * This structure must be the first member of the data structure in
 * the rbtree.  This allows easy casting between an rbnode_t and the
 * user data (poor man's inheritance).
 */

I.e. it seems to imply that one must put user data just after
ldns_rbnode_t in memory, and nowhere else (in other words, pass a
pointer to not_only_rbnode_t to ldns_rbtree_insert()).

However, there is also a data pointer in ldns_rbnode_t, and if one
follows the existing practice established in dnssec_zone.c, he puts the
user data into the allocates memory there and inserts pointers to plain
ldns_rbnode_t to the tree.

Am I right that I am in fact free to choose any of the two above
strategies for placing the user data, and that both are supported? Which
one is preferred under which conditions?

-- 
Alexander E. Patrakov




More information about the ldns-users mailing list