lhash.3 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. .\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .if !\nF .nr F 0
  58. .if \nF>0 \{\
  59. . de IX
  60. . tm Index:\\$1\t\\n%\t"\\$2"
  61. ..
  62. . if !\nF==2 \{\
  63. . nr % 0
  64. . nr F 2
  65. . \}
  66. .\}
  67. .\"
  68. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  69. .\" Fear. Run. Save yourself. No user-serviceable parts.
  70. . \" fudge factors for nroff and troff
  71. .if n \{\
  72. . ds #H 0
  73. . ds #V .8m
  74. . ds #F .3m
  75. . ds #[ \f1
  76. . ds #] \fP
  77. .\}
  78. .if t \{\
  79. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  80. . ds #V .6m
  81. . ds #F 0
  82. . ds #[ \&
  83. . ds #] \&
  84. .\}
  85. . \" simple accents for nroff and troff
  86. .if n \{\
  87. . ds ' \&
  88. . ds ` \&
  89. . ds ^ \&
  90. . ds , \&
  91. . ds ~ ~
  92. . ds /
  93. .\}
  94. .if t \{\
  95. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  96. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  97. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  98. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  99. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  100. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  101. .\}
  102. . \" troff and (daisy-wheel) nroff accents
  103. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  104. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  105. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  106. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  107. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  108. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  109. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  110. .ds ae a\h'-(\w'a'u*4/10)'e
  111. .ds Ae A\h'-(\w'A'u*4/10)'E
  112. . \" corrections for vroff
  113. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  114. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  115. . \" for low resolution devices (crt and lpr)
  116. .if \n(.H>23 .if \n(.V>19 \
  117. \{\
  118. . ds : e
  119. . ds 8 ss
  120. . ds o a
  121. . ds d- d\h'-1'\(ga
  122. . ds D- D\h'-1'\(hy
  123. . ds th \o'bp'
  124. . ds Th \o'LP'
  125. . ds ae ae
  126. . ds Ae AE
  127. .\}
  128. .rm #[ #] #H #V #F C
  129. .\" ========================================================================
  130. .\"
  131. .IX Title "lhash 3"
  132. .TH lhash 3 "2019-09-12" "1.0.2g" "OpenSSL"
  133. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  134. .\" way too many mistakes in technical documents.
  135. .if n .ad l
  136. .nh
  137. .SH "NAME"
  138. lh_new, lh_free, lh_insert, lh_delete, lh_retrieve, lh_doall, lh_doall_arg, lh_error \- dynamic hash table
  139. .SH "SYNOPSIS"
  140. .IX Header "SYNOPSIS"
  141. .Vb 1
  142. \& #include <openssl/lhash.h>
  143. \&
  144. \& DECLARE_LHASH_OF(<type>);
  145. \&
  146. \& LHASH *lh_<type>_new();
  147. \& void lh_<type>_free(LHASH_OF(<type> *table);
  148. \&
  149. \& <type> *lh_<type>_insert(LHASH_OF(<type> *table, <type> *data);
  150. \& <type> *lh_<type>_delete(LHASH_OF(<type> *table, <type> *data);
  151. \& <type> *lh_retrieve(LHASH_OF<type> *table, <type> *data);
  152. \&
  153. \& void lh_<type>_doall(LHASH_OF(<type> *table, LHASH_DOALL_FN_TYPE func);
  154. \& void lh_<type>_doall_arg(LHASH_OF(<type> *table, LHASH_DOALL_ARG_FN_TYPE func,
  155. \& <type2>, <type2> *arg);
  156. \&
  157. \& int lh_<type>_error(LHASH_OF(<type> *table);
  158. \&
  159. \& typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
  160. \& typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
  161. \& typedef void (*LHASH_DOALL_FN_TYPE)(const void *);
  162. \& typedef void (*LHASH_DOALL_ARG_FN_TYPE)(const void *, const void *);
  163. .Ve
  164. .SH "DESCRIPTION"
  165. .IX Header "DESCRIPTION"
  166. This library implements type-checked dynamic hash tables. The hash
  167. table entries can be arbitrary structures. Usually they consist of key
  168. and value fields.
  169. .PP
  170. lh_<type>\fI_new()\fR creates a new \fB\s-1LHASH_OF\s0(<type\fR> structure to store
  171. arbitrary data entries, and provides the 'hash' and 'compare'
  172. callbacks to be used in organising the table's entries. The \fBhash\fR
  173. callback takes a pointer to a table entry as its argument and returns
  174. an unsigned long hash value for its key field. The hash value is
  175. normally truncated to a power of 2, so make sure that your hash
  176. function returns well mixed low order bits. The \fBcompare\fR callback
  177. takes two arguments (pointers to two hash table entries), and returns
  178. 0 if their keys are equal, non-zero otherwise. If your hash table
  179. will contain items of some particular type and the \fBhash\fR and
  180. \&\fBcompare\fR callbacks hash/compare these types, then the
  181. \&\fB\s-1DECLARE_LHASH_HASH_FN\s0\fR and \fB\s-1IMPLEMENT_LHASH_COMP_FN\s0\fR macros can be
  182. used to create callback wrappers of the prototypes required by
  183. lh_<type>\fI_new()\fR. These provide per-variable casts before calling the
  184. type-specific callbacks written by the application author. These
  185. macros, as well as those used for the \*(L"doall\*(R" callbacks, are defined
  186. as;
  187. .PP
  188. .Vb 7
  189. \& #define DECLARE_LHASH_HASH_FN(name, o_type) \e
  190. \& unsigned long name##_LHASH_HASH(const void *);
  191. \& #define IMPLEMENT_LHASH_HASH_FN(name, o_type) \e
  192. \& unsigned long name##_LHASH_HASH(const void *arg) { \e
  193. \& const o_type *a = arg; \e
  194. \& return name##_hash(a); }
  195. \& #define LHASH_HASH_FN(name) name##_LHASH_HASH
  196. \&
  197. \& #define DECLARE_LHASH_COMP_FN(name, o_type) \e
  198. \& int name##_LHASH_COMP(const void *, const void *);
  199. \& #define IMPLEMENT_LHASH_COMP_FN(name, o_type) \e
  200. \& int name##_LHASH_COMP(const void *arg1, const void *arg2) { \e
  201. \& const o_type *a = arg1; \e
  202. \& const o_type *b = arg2; \e
  203. \& return name##_cmp(a,b); }
  204. \& #define LHASH_COMP_FN(name) name##_LHASH_COMP
  205. \&
  206. \& #define DECLARE_LHASH_DOALL_FN(name, o_type) \e
  207. \& void name##_LHASH_DOALL(void *);
  208. \& #define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \e
  209. \& void name##_LHASH_DOALL(void *arg) { \e
  210. \& o_type *a = arg; \e
  211. \& name##_doall(a); }
  212. \& #define LHASH_DOALL_FN(name) name##_LHASH_DOALL
  213. \&
  214. \& #define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \e
  215. \& void name##_LHASH_DOALL_ARG(void *, void *);
  216. \& #define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \e
  217. \& void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \e
  218. \& o_type *a = arg1; \e
  219. \& a_type *b = arg2; \e
  220. \& name##_doall_arg(a, b); }
  221. \& #define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG
  222. \&
  223. \& An example of a hash table storing (pointers to) structures of type \*(AqSTUFF\*(Aq
  224. \& could be defined as follows;
  225. \&
  226. \& /* Calculates the hash value of \*(Aqtohash\*(Aq (implemented elsewhere) */
  227. \& unsigned long STUFF_hash(const STUFF *tohash);
  228. \& /* Orders \*(Aqarg1\*(Aq and \*(Aqarg2\*(Aq (implemented elsewhere) */
  229. \& int stuff_cmp(const STUFF *arg1, const STUFF *arg2);
  230. \& /* Create the type\-safe wrapper functions for use in the LHASH internals */
  231. \& static IMPLEMENT_LHASH_HASH_FN(stuff, STUFF);
  232. \& static IMPLEMENT_LHASH_COMP_FN(stuff, STUFF);
  233. \& /* ... */
  234. \& int main(int argc, char *argv[]) {
  235. \& /* Create the new hash table using the hash/compare wrappers */
  236. \& LHASH_OF(STUFF) *hashtable = lh_STUFF_new(LHASH_HASH_FN(STUFF_hash),
  237. \& LHASH_COMP_FN(STUFF_cmp));
  238. \& /* ... */
  239. \& }
  240. .Ve
  241. .PP
  242. lh_<type>\fI_free()\fR frees the \fB\s-1LHASH_OF\s0(<type\fR> structure
  243. \&\fBtable\fR. Allocated hash table entries will not be freed; consider
  244. using lh_<type>\fI_doall()\fR to deallocate any remaining entries in the
  245. hash table (see below).
  246. .PP
  247. lh_<type>\fI_insert()\fR inserts the structure pointed to by \fBdata\fR into
  248. \&\fBtable\fR. If there already is an entry with the same key, the old
  249. value is replaced. Note that lh_<type>\fI_insert()\fR stores pointers, the
  250. data are not copied.
  251. .PP
  252. lh_<type>\fI_delete()\fR deletes an entry from \fBtable\fR.
  253. .PP
  254. lh_<type>\fI_retrieve()\fR looks up an entry in \fBtable\fR. Normally, \fBdata\fR
  255. is a structure with the key field(s) set; the function will return a
  256. pointer to a fully populated structure.
  257. .PP
  258. lh_<type>\fI_doall()\fR will, for every entry in the hash table, call
  259. \&\fBfunc\fR with the data item as its parameter. For lh_<type>\fI_doall()\fR
  260. and lh_<type>\fI_doall_arg()\fR, function pointer casting should be avoided
  261. in the callbacks (see \fB\s-1NOTE\s0\fR) \- instead use the declare/implement
  262. macros to create type-checked wrappers that cast variables prior to
  263. calling your type-specific callbacks. An example of this is
  264. illustrated here where the callback is used to cleanup resources for
  265. items in the hash table prior to the hashtable itself being
  266. deallocated:
  267. .PP
  268. .Vb 9
  269. \& /* Cleans up resources belonging to \*(Aqa\*(Aq (this is implemented elsewhere) */
  270. \& void STUFF_cleanup_doall(STUFF *a);
  271. \& /* Implement a prototype\-compatible wrapper for "STUFF_cleanup" */
  272. \& IMPLEMENT_LHASH_DOALL_FN(STUFF_cleanup, STUFF)
  273. \& /* ... then later in the code ... */
  274. \& /* So to run "STUFF_cleanup" against all items in a hash table ... */
  275. \& lh_STUFF_doall(hashtable, LHASH_DOALL_FN(STUFF_cleanup));
  276. \& /* Then the hash table itself can be deallocated */
  277. \& lh_STUFF_free(hashtable);
  278. .Ve
  279. .PP
  280. When doing this, be careful if you delete entries from the hash table
  281. in your callbacks: the table may decrease in size, moving the item
  282. that you are currently on down lower in the hash table \- this could
  283. cause some entries to be skipped during the iteration. The second
  284. best solution to this problem is to set hash\->down_load=0 before
  285. you start (which will stop the hash table ever decreasing in size).
  286. The best solution is probably to avoid deleting items from the hash
  287. table inside a \*(L"doall\*(R" callback!
  288. .PP
  289. lh_<type>\fI_doall_arg()\fR is the same as lh_<type>\fI_doall()\fR except that
  290. \&\fBfunc\fR will be called with \fBarg\fR as the second argument and \fBfunc\fR
  291. should be of type \fB\s-1LHASH_DOALL_ARG_FN_TYPE\s0\fR (a callback prototype
  292. that is passed both the table entry and an extra argument). As with
  293. \&\fIlh_doall()\fR, you can instead choose to declare your callback with a
  294. prototype matching the types you are dealing with and use the
  295. declare/implement macros to create compatible wrappers that cast
  296. variables before calling your type-specific callbacks. An example of
  297. this is demonstrated here (printing all hash table entries to a \s-1BIO\s0
  298. that is provided by the caller):
  299. .PP
  300. .Vb 8
  301. \& /* Prints item \*(Aqa\*(Aq to \*(Aqoutput_bio\*(Aq (this is implemented elsewhere) */
  302. \& void STUFF_print_doall_arg(const STUFF *a, BIO *output_bio);
  303. \& /* Implement a prototype\-compatible wrapper for "STUFF_print" */
  304. \& static IMPLEMENT_LHASH_DOALL_ARG_FN(STUFF, const STUFF, BIO)
  305. \& /* ... then later in the code ... */
  306. \& /* Print out the entire hashtable to a particular BIO */
  307. \& lh_STUFF_doall_arg(hashtable, LHASH_DOALL_ARG_FN(STUFF_print), BIO,
  308. \& logging_bio);
  309. .Ve
  310. .PP
  311. lh_<type>\fI_error()\fR can be used to determine if an error occurred in the last
  312. operation. lh_<type>\fI_error()\fR is a macro.
  313. .SH "RETURN VALUES"
  314. .IX Header "RETURN VALUES"
  315. lh_<type>\fI_new()\fR returns \fB\s-1NULL\s0\fR on error, otherwise a pointer to the new
  316. \&\fB\s-1LHASH\s0\fR structure.
  317. .PP
  318. When a hash table entry is replaced, lh_<type>\fI_insert()\fR returns the value
  319. being replaced. \fB\s-1NULL\s0\fR is returned on normal operation and on error.
  320. .PP
  321. lh_<type>\fI_delete()\fR returns the entry being deleted. \fB\s-1NULL\s0\fR is returned if
  322. there is no such value in the hash table.
  323. .PP
  324. lh_<type>\fI_retrieve()\fR returns the hash table entry if it has been found,
  325. \&\fB\s-1NULL\s0\fR otherwise.
  326. .PP
  327. lh_<type>\fI_error()\fR returns 1 if an error occurred in the last operation, 0
  328. otherwise.
  329. .PP
  330. lh_<type>\fI_free()\fR, lh_<type>\fI_doall()\fR and lh_<type>\fI_doall_arg()\fR return no values.
  331. .SH "NOTE"
  332. .IX Header "NOTE"
  333. The various \s-1LHASH\s0 macros and callback types exist to make it possible
  334. to write type-checked code without resorting to function-prototype
  335. casting \- an evil that makes application code much harder to
  336. audit/verify and also opens the window of opportunity for stack
  337. corruption and other hard-to-find bugs. It also, apparently, violates
  338. ANSI-C.
  339. .PP
  340. The \s-1LHASH\s0 code regards table entries as constant data. As such, it
  341. internally represents \fIlh_insert()\fR'd items with a \*(L"const void *\*(R"
  342. pointer type. This is why callbacks such as those used by \fIlh_doall()\fR
  343. and \fIlh_doall_arg()\fR declare their prototypes with \*(L"const\*(R", even for the
  344. parameters that pass back the table items' data pointers \- for
  345. consistency, user-provided data is \*(L"const\*(R" at all times as far as the
  346. \&\s-1LHASH\s0 code is concerned. However, as callers are themselves providing
  347. these pointers, they can choose whether they too should be treating
  348. all such parameters as constant.
  349. .PP
  350. As an example, a hash table may be maintained by code that, for
  351. reasons of encapsulation, has only \*(L"const\*(R" access to the data being
  352. indexed in the hash table (ie. it is returned as \*(L"const\*(R" from
  353. elsewhere in their code) \- in this case the \s-1LHASH\s0 prototypes are
  354. appropriate as-is. Conversely, if the caller is responsible for the
  355. life-time of the data in question, then they may well wish to make
  356. modifications to table item passed back in the \fIlh_doall()\fR or
  357. \&\fIlh_doall_arg()\fR callbacks (see the \*(L"STUFF_cleanup\*(R" example above). If
  358. so, the caller can either cast the \*(L"const\*(R" away (if they're providing
  359. the raw callbacks themselves) or use the macros to declare/implement
  360. the wrapper functions without \*(L"const\*(R" types.
  361. .PP
  362. Callers that only have \*(L"const\*(R" access to data they're indexing in a
  363. table, yet declare callbacks without constant types (or cast the
  364. \&\*(L"const\*(R" away themselves), are therefore creating their own risks/bugs
  365. without being encouraged to do so by the \s-1API.\s0 On a related note,
  366. those auditing code should pay special attention to any instances of
  367. DECLARE/IMPLEMENT_LHASH_DOALL_[\s-1ARG_\s0]_FN macros that provide types
  368. without any \*(L"const\*(R" qualifiers.
  369. .SH "BUGS"
  370. .IX Header "BUGS"
  371. lh_<type>\fI_insert()\fR returns \fB\s-1NULL\s0\fR both for success and error.
  372. .SH "INTERNALS"
  373. .IX Header "INTERNALS"
  374. The following description is based on the SSLeay documentation:
  375. .PP
  376. The \fBlhash\fR library implements a hash table described in the
  377. \&\fICommunications of the \s-1ACM\s0\fR in 1991. What makes this hash table
  378. different is that as the table fills, the hash table is increased (or
  379. decreased) in size via \fIOPENSSL_realloc()\fR. When a 'resize' is done, instead of
  380. all hashes being redistributed over twice as many 'buckets', one
  381. bucket is split. So when an 'expand' is done, there is only a minimal
  382. cost to redistribute some values. Subsequent inserts will cause more
  383. single 'bucket' redistributions but there will never be a sudden large
  384. cost due to redistributing all the 'buckets'.
  385. .PP
  386. The state for a particular hash table is kept in the \fB\s-1LHASH\s0\fR structure.
  387. The decision to increase or decrease the hash table size is made
  388. depending on the 'load' of the hash table. The load is the number of
  389. items in the hash table divided by the size of the hash table. The
  390. default values are as follows. If (hash\->up_load < load) =>
  391. expand. if (hash\->down_load > load) => contract. The
  392. \&\fBup_load\fR has a default value of 1 and \fBdown_load\fR has a default value
  393. of 2. These numbers can be modified by the application by just
  394. playing with the \fBup_load\fR and \fBdown_load\fR variables. The 'load' is
  395. kept in a form which is multiplied by 256. So
  396. hash\->up_load=8*256; will cause a load of 8 to be set.
  397. .PP
  398. If you are interested in performance the field to watch is
  399. num_comp_calls. The hash library keeps track of the 'hash' value for
  400. each item so when a lookup is done, the 'hashes' are compared, if
  401. there is a match, then a full compare is done, and
  402. hash\->num_comp_calls is incremented. If num_comp_calls is not equal
  403. to num_delete plus num_retrieve it means that your hash function is
  404. generating hashes that are the same for different values. It is
  405. probably worth changing your hash function if this is the case because
  406. even if your hash table has 10 items in a 'bucket', it can be searched
  407. with 10 \fBunsigned long\fR compares and 10 linked list traverses. This
  408. will be much less expensive that 10 calls to your compare function.
  409. .PP
  410. \&\fIlh_strhash()\fR is a demo string hashing function:
  411. .PP
  412. .Vb 1
  413. \& unsigned long lh_strhash(const char *c);
  414. .Ve
  415. .PP
  416. Since the \fB\s-1LHASH\s0\fR routines would normally be passed structures, this
  417. routine would not normally be passed to lh_<type>\fI_new()\fR, rather it would be
  418. used in the function passed to lh_<type>\fI_new()\fR.
  419. .SH "SEE ALSO"
  420. .IX Header "SEE ALSO"
  421. \&\fIlh_stats\fR\|(3)
  422. .SH "HISTORY"
  423. .IX Header "HISTORY"
  424. The \fBlhash\fR library is available in all versions of SSLeay and OpenSSL.
  425. \&\fIlh_error()\fR was added in SSLeay 0.9.1b.
  426. .PP
  427. This manpage is derived from the SSLeay documentation.
  428. .PP
  429. In OpenSSL 0.9.7, all lhash functions that were passed function pointers
  430. were changed for better type safety, and the function types \s-1LHASH_COMP_FN_TYPE,
  431. LHASH_HASH_FN_TYPE, LHASH_DOALL_FN_TYPE\s0 and \s-1LHASH_DOALL_ARG_FN_TYPE\s0
  432. became available.
  433. .PP
  434. In OpenSSL 1.0.0, the lhash interface was revamped for even better
  435. type checking.