Date: Sun, 3 Aug 2025 23:18:04 +0100 From: Lexi Winter <ivy@freebsd.org> To: hackers@freebsd.org Subject: Re: help with pctrie Message-ID: <aI_gHHh8wceC2Fxp@freefall.freebsd.org> In-Reply-To: <aI_YPe5IyNsY00hR@nuc> References: <aI-3A3FVDyO-qU4y@freefall.freebsd.org> <aI_YPe5IyNsY00hR@nuc>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] Mark Johnston: > On Sun, Aug 03, 2025 at 08:22:43PM +0100, Lexi Winter wrote: > > i'm trying to use <sys/pctrie.h> and running into a problem i don't > > really understand. since it's largely undocumented, this is probably > > something i'm doing wrong rather than bug, but i can't work out what. > I think the problem there is that you're missing a > FDB_PCTRIE_ITER_LOOKUP() to return the value at the current position in > the iterator. The general pattern should be something like: thanks to Mark's explanation (+ discussion on IRC) i worked out what's wrong: to iterate all entries in a pctrie, you need to start by calling xxx_PCTRIE_ITER_LOOKUP_GE(iter, 0), then for each iteration, call xxx_PCTRIE_ITER_STEP_GE(iter). xxx_PCTRIE_ITER_NEXT was named to confuse C++ programmers and actually means "add 1 to the current node and return that or NULL", so we should never use that. [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSyjTg96lp3RifySyn1nT63mIK/YAUCaI/gGAAKCRD1nT63mIK/ YEsBAQC1rAREGZB0j10mQTxRbOCZlxgqdNzkfHuI4s9zL2jcZAEArLpX0adK6Ip/ LeeELn9DAYqTLpVOnIVDMI6+UbCNCwU= =oXha -----END PGP SIGNATURE-----home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?aI_gHHh8wceC2Fxp>
