Programming with Judy

Example of a Multi-dimensional Array
Example Code
Chapter 4 51
// ****************************************************************************
//JUDY SL GET
PPvoid_t JudySLGet (
const void * PArray,
const char * Index,
JError_t * PJError)
{
char * pos = (char *)Index; // place in Index.
ulong_t indexword; // next word to find.
PPvoid_t PPvalue; // from JudyL array.
assert (Index != PCNULL);
// SEARCH NEXT LEVEL OF JUDYL ARRAY IN TREE:
//
// Copy each word from the Index string and check for it in the next level
// JudyL array in the array tree.
while (TRUE) // until return.
{
// Since strings can begin on arbitrary byte boundaries, copy each
// chunk of N bytes from Index into a word-aligned object (a ulong_t)
// before using it as a Judy index.
WORDCPY (& indexword, pos);
if ((PPvalue = JudyLGet (PArray, indexword, PJError)) == PPJERR)
return (PPVNULL); // Index not in array tree.