Alien-Judy
view release on metacpan or search on metacpan
src/judy-1.0.5/src/Judy.h view on Meta::CPAN
// JUDYHSL FUNCTIONS:
extern PPvoid_t JudyHSGet( Pcvoid_t, void *, Word_t);
extern PPvoid_t JudyHSIns( PPvoid_t, void *, Word_t, P_JE);
extern int JudyHSDel( PPvoid_t, void *, Word_t, P_JE);
extern Word_t JudyHSFreeArray( PPvoid_t, P_JE);
extern const char *Judy1MallocSizes;
extern const char *JudyLMallocSizes;
// ****************************************************************************
// JUDY memory interface to malloc() FUNCTIONS:
extern Word_t JudyMalloc(Word_t); // words reqd => words allocd.
extern Word_t JudyMallocVirtual(Word_t); // words reqd => words allocd.
extern void JudyFree(Pvoid_t, Word_t); // free, size in words.
extern void JudyFreeVirtual(Pvoid_t, Word_t); // free, size in words.
#define JLAP_INVALID 0x1 /* flag to mark pointer "not a Judy array" */
// ****************************************************************************
// MACRO EQUIVALENTS FOR JUDY FUNCTIONS:
//
// The following macros, such as J1T, are shorthands for calling Judy functions
// with parameter address-of and detailed error checking included. Since they
// are macros, the error checking code is replicated each time the macro is
// used, but it runs fast in the normal case of no error.
//
// If the caller does not like the way the default JUDYERROR macro handles
// errors (such as an exit(1) call when out of memory), they may define their
// own before the "#include <Judy.h>". A routine such as HandleJudyError
// could do checking on specific error numbers and print a different message
// dependent on the error. The following is one example:
//
// Note: the back-slashes are removed because some compilers will not accept
// them in comments.
//
// void HandleJudyError(uint8_t *, int, uint8_t *, int, int);
// #define JUDYERROR(CallerFile, CallerLine, JudyFunc, JudyErrno, JudyErrID)
// {
// HandleJudyError(CallerFile, CallerLine, JudyFunc, JudyErrno, JudyErrID);
// }
//
// The routine HandleJudyError could do checking on specific error numbers and
// print a different message dependent on the error.
//
// The macro receives five parameters that are:
//
// 1. CallerFile: Source filename where a Judy call returned a serious error.
// 2. CallerLine: Line number in that source file.
// 3. JudyFunc: Name of Judy function reporting the error.
// 4. JudyErrno: One of the JU_ERRNO* values enumerated above.
// 5. JudyErrID: The je_ErrID field described above.
#ifndef JUDYERROR_NOTEST
#ifndef JUDYERROR /* supply a default error macro */
#include <stdio.h>
#define JUDYERROR(CallerFile, CallerLine, JudyFunc, JudyErrno, JudyErrID) \
{ \
(void) fprintf(stderr, "File '%s', line %d: %s(), " \
"JU_ERRNO_* == %d, ID == %d\n", \
CallerFile, CallerLine, \
JudyFunc, JudyErrno, JudyErrID); \
exit(1); \
}
#endif /* JUDYERROR */
#endif /* JUDYERROR_NOTEST */
// If the JUDYERROR macro is not desired at all, then the following eliminates
// it. However, the return code from each Judy function (that is, the first
// parameter of each macro) must be checked by the caller to assure that an
// error did not occur.
//
// Example:
//
// #define JUDYERROR_NOTEST 1
// #include <Judy.h>
//
// or use this cc option at compile time:
//
// cc -DJUDYERROR_NOTEST ...
//
// Example code:
//
// J1S(Rc, PArray, Index);
// if (Rc == JERR) goto ...error
//
// or:
//
// JLI(PValue, PArray, Index);
// if (PValue == PJERR) goto ...error
// Internal shorthand macros for writing the J1S, etc. macros:
#ifdef JUDYERROR_NOTEST /* ============================================ */
// "Judy Set Error":
#define J_SE(FuncName,Errno) ((void) 0)
// Note: In each J_*() case below, the digit is the number of key parameters
// to the Judy*() call. Just assign the Func result to the callers Rc value
// without a cast because none is required, and this keeps the API simpler.
// However, a family of different J_*() macros is needed to support the
// different numbers of key parameters (0,1,2) and the Func return type.
//
// In the names below, "I" = integer result; "P" = pointer result. Note, the
// Funcs for J_*P() return PPvoid_t, but cast this to a Pvoid_t for flexible,
// error-free assignment, and then compare to PJERR.
#define J_0I(Rc,PArray,Func,FuncName) \
{ (Rc) = Func(PArray, PJE0); }
#define J_1I(Rc,PArray,Index,Func,FuncName) \
{ (Rc) = Func(PArray, Index, PJE0); }
#define J_1P(PV,PArray,Index,Func,FuncName) \
{ (PV) = (Pvoid_t) Func(PArray, Index, PJE0); }
( run in 0.399 second using v1.01-cache-2.11-cpan-39bf76dae61 )