pctrie: change for vm_radix compatibility
Restructure parts of pctrie code to make it more compatible with the
needs of vm_radix code.
- End passing function pointers for memory management.
By breaking insertion into two functions, the call for allocating
memory can happen at the top level and be inlined, rather than
happening via an function pointer to a memory allocator.
By changing the remove function slightly, freeing of memory, when
necessary, can happen at the top level and be inlined.
By turning the reclamation code into two functions, one for starting
iteration over to-be-freed nodes and the other continuing it, all the
freeing can happen at the top level and be inlined.
- Offer a version of remove that does not panic and returns the freed
value (or NULL).
- Offer a 'replace' operation, to replace one leaf with another that
has the same key.
These are three of the roadblocks that prevent code sharing between
pctrie and vm_radix code.
Reviewed by: kib (previous version)
Differential Revision: https://reviews.freebsd.org/D41396