Debian Codegraph @

doc/ext/JudyHS_funcs_3.htm

raw
1 <HTML>
2 <HEAD>
3 <!-- @(#) $Revision: 4.5 $ $Source: /cvsroot/judy/doc/ext/JudyHS_funcs_3.htm,v $ --->
4 <TITLE>JudyHS_funcs(3)</TITLE>
5 </HEAD>
6 <BODY>
7 <TABLE border=0 width="100%"><TR>
8 <TD width="40%" align="left">JudyHS_funcs(3)</TD>
9 <TD width="10%" align="center"> </TD>
10 <TD width="40%" align="right">JudyHS_funcs(3)</TD>
11 </TR></TABLE>
12 <P>
13 <DL>
14 <!----------------->
15 <DT><B>NAME</B></DT>
16 <DD>
17 JudyHS functions -
18 C library for creating and accessing a dynamic array,
19 using an array-of-bytes of a length: <B>Length</B> as an <B>Index</B> and a word
20 as a <B>Value</B>.
21 <!----------------->
22 <P>
23 <DT><B>SYNOPSIS</B></DT>
24 <DD>
25 <B><PRE>
26 PPvoid_t <A href="#JudyHSIns" >JudyHSIns</A>(PPvoid_t PPJHS, void *Index, Word_t Length, PJError_t PJError);
27 int <A href="#JudyHSDel" >JudyHSDel</A>(PPvoid_t PPJHS, void *Index, Word_t Length, PJError_t PJError);
28 PPvoid_t <A href="#JudyHSGet" >JudyHSGet</A>(Pcvoid_t PJHS, void *Index, Word_t Length, PJError_t PJError);
29 Word_t <A href="#JudyHSFreeArray">JudyHSFreeArray</A>(PPvoid_t PPJHS, PJError_t PJError);
30 </PRE></B>
31 <!----------------->
32 <P>
33 <DT><B>DESCRIPTION</B></DT>
34 <DD>
35 A macro equivalent exists for each function call. Because the macro
36 forms are sometimes faster and have a simpler error handling interface
37 than the equivalent functions, they are the preferred way of calling the
38 JudyHS functions.
39 See <A href="JudyHS_3.htm">JudyHS(3)</A>
40 for more information.
41 The function call definitions are included here for completeness.
42 <P>
43 One of the difficulties in using the JudyHS function calls lies in
44 determining whether to pass a pointer or the address of a pointer.
45 Since the functions that modify the JudyHS array must also modify the
46 pointer to the JudyHS array, you must pass the address of the pointer
47 rather than the pointer itself.
48 This often leads to hard-to-debug programmatic errors.
49 In practice, the macros allow the compiler to catch programming
50 errors when pointers instead of addresses of pointers are passed.
51 <P>
52 The JudyHS function calls have an additional parameter beyond those
53 specified in the macro calls. This parameter is either a pointer to an
54 error structure, or <B>NULL</B> (in which case the error information is
55 not returned -- only <B>PJERR</B> in the return parameter).
56 <P>
57 In the following descriptions, the functions are described in
58 terms of how the macros use them.
59 This is the suggested use
60 of the macros after your program has been fully debugged.
61 When the <B>JUDYERROR_NOTEST</B> macro is not specified,
62 an error structure is declared to store error information
63 returned from the JudyHS functions when an error occurs.
64 <P>
65 Notice the placement of the <B>&amp;</B> in the different functions.
66 <P>
67 <DL>
68 <DT><A name="JudyHSIns"><B>JudyHSIns(&amp;PJHS, Index, Length, &amp;JError)</B></A></DT>
69 <DD>
70 <PRE>
71 #define JHSI(PValue, PJHS, Index) \
72 PValue = JudyLIns(&amp;PJHS, Index, PJE0)
73
74 </PRE>
75 <P>
76 <DT><A name="JudyHSDel"><B>JudyHSDel(&amp;PJHS, Index, Length, &amp;JError)</B></A></DT>
77 <DD>
78 <PRE>
79 #define JHSD(Rc_int, PJHS, Index, Length) \
80 Rc_int = JudyHSDel(&amp;PJHS, Index, Length, PJE0)
81
82 </PRE>
83 <P>
84 <DT><A name="JudyHSGet"><B>JudyHSGet(PJHS, Index, Length)</B></A></DT>
85 <DD>
86 <PRE>
87 #define JHSG(PValue, PJHS, Index, Length) \
88 PValue = JudyHSIns(PJHS, Index, Length)
89
90 </PRE>
91 <P>
92 <DT><A name="JudyHSFreeArray"><B>JudyHSFreeArray(&amp;PJHS, &amp;JError)</B></A></DT>
93 <DD>
94 <PRE>
95 #define JHSFA(Rc_word, PJHS) \
96 Rc_word = JudyHSFreeArray(&amp;PJHS, PJE0)
97
98 </PRE>
99 </DL>
100 <P>
101 Definitions for all the Judy functions, the types
102 <B>Pvoid_t</B>,
103 <B>Pcvoid_t</B>,
104 <B>PPvoid_t</B>,
105 <B>Word_t </B>,
106 <B>JError_t</B>,
107 and
108 <B>PJError_t</B>,
109 the constants
110 <B>NULL</B>,
111 <B>JU_ERRNO_*</B>,
112 <B>JERR</B>,
113 <B>PPJERR</B>,
114 and
115 <B>PJE0</B>
116 are provided in the <B>Judy.h</B> header file
117 (/usr/include/Judy.h).
118 <B>Note</B>: Callers should define JudyHS arrays as type <B>Pvoid_t</B>,
119 which can be passed by value to functions that take
120 <B>Pcvoid_t</B> (constant <B>Pvoid_t</B>),
121 and also by address to functions that take <B>PPvoid_t</B>.
122 <P>
123 The return type from most <B>JudyHS</B> functions is <B>PPvoid_t</B> so
124 that the values stored in the array can be pointers to other objects,
125 which is a typical usage, or cast to a <B>Word_t *</B> when a pointer
126 to a value is required instead of a pointer to a pointer.
127 <!----------------->
128 <P>
129 <DT><B>AUTHOR</B></DT>
130 <DD>
131 JudyHS was invented and implemented by Doug Baskins after retiring from Hewlett-Packard.
132 <!----------------->
133 <P>
134 <DT><B>SEE ALSO</B></DT>
135 <DD>
136 <A href="Judy_3.htm">Judy(3)</A>,
137 <A href="Judy1_3.htm">Judy1(3)</A>,
138 <A href="JudyL_3.htm">JudyL(3)</A>,
139 <A href="JudySL_3.htm">JudySL(3)</A>,
140 <A href="JudyHS_3.htm">JudyHS(3)</A>,
141 <BR>
142 <I>malloc()</I>,
143 <BR>
144 the Judy website,
145 <A href="http://judy.sourceforge.net">
146 http://judy.sourceforge.net</A>,
147 for more information and Application Notes.
148 </DL>
149 </BODY>
150 </HTML>