Adding RB_NFIND() to sys/tree.h
Gleb Smirnoff
glebius at FreeBSD.org
Wed Dec 28 12:37:23 PST 2005
On Wed, Dec 28, 2005 at 06:58:20AM -0800, Jason Evans wrote:
J> [This is a slightly edited copy of email originally sent to -
J> current. The only response I received was that -arch is a better
J> list on which to ask for feedback on this issue.]
J>
J> I'd like to add RB_NFIND() to sys/tree.h, since I need it for the
J> malloc implementation I've been working on. sys/tree.h comes from
J> NetBSD, and up to now, the only changes we've made have been for the
J> purpose of avoiding compiler warnings.
J>
J> RB_NFIND() is like RB_FIND(), but if an exact match isn't found,
J> RB_NFIND() returns the next object in the tree (if there is one).
J> Emulating RB_NFIND() with the existing RB_*() API is possible, but
J> certainly not ideal.
J>
J> I would claim that RB_PFIND() isn't necessary, since it could be
J> easily (if not quite as efficiently) emulated with RB_NFIND(),
J> followed by RB_PREV(). However, there is no RB_PREV(), even though
J> there is RB_NEXT(). This seems to me like an API design oversight
J> (as is the omission of RB_FOREACH_REVERSE()), but it doesn't cause me
J> issues, so I haven't tackled it.
J>
J> A patch follows (manpage changes omitted). Are there any objections
J> to committing this?
I see it useful, and probably will utilize soon in ipfw(4). Thanks.
--
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE
More information about the freebsd-arch
mailing list