Programming with Judy
Example of a Multi-dimensional Array
Example Code
Chapter 450
Example Code
#include "Judy.h"
#define TRUE 1L
#define CHNULL '\0'
#define PCNULL ((char *) NULL)
#define PPVNULL ((PPvoid_t) NULL)
#define WORDSIZE (sizeof (ulong_t)) // bytes in a word = JudyL index.
// Copy a word from one location to another; typically one of which is not
// word-aligned:
//
// Like strncpy(), null-pad the destination, but based on performance
// measurements don't use strncpy(). Instead hardwire the code based on a
// parameter from JudyL.h; assume only two machine word sizes exist.
#define CH(P,I) (((char *) (P)) [I]) // shorthand for below.
#define CPY(P1,P2,I) (CH (P1, I) = CH (P2, I))
#define IFCPY(P1,P2,I) if (CPY (P1, P2, I) != CHNULL)
#define WORDCPY(P1,P2) \
{ *((ulong_t *) (P1)) = 0L; \
IFCPY(P1,P2,0L) IFCPY(P1,P2,1L) IFCPY(P1,P2,2L) CPY(P1,P2,3L); }
#define LASTWORD(indexword) (((char *) (& indexword)) [WORDSIZE - 1L] == CHNULL)