]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libopenbsd/ohash_interval.3
Make linux_ptrace() use linux_msg() instead of printf().
[FreeBSD/FreeBSD.git] / lib / libopenbsd / ohash_interval.3
1 .\"     $OpenBSD: ohash_interval.3,v 1.1 2014/05/12 19:09:00 espie Exp $
2 .\" Copyright (c) 2001 Marc Espie <espie@openbsd.org>
3 .\"
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
7 .\"
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 .\"
16 .\" $FreeBSD$
17 .\"
18 .Dd June 5, 2013
19 .Dt OHASH_INTERVAL 3
20 .Os
21 .Sh NAME
22 .Nm ohash_interval ,
23 .Nm ohash_create_entry ,
24 .Nm ohash_qlookup ,
25 .Nm ohash_qlookupi
26 .Nd helper functions for open hashing
27 .Sh SYNOPSIS
28 .In stdint.h
29 .In stddef.h
30 .In ohash.h
31 .Ft uint32_t
32 .Fn ohash_interval "const char *start" "const char **pend"
33 .Ft "void *"
34 .Fn ohash_create_entry "struct ohash_info *info" "const char *start" "const char **pend"
35 .Ft "unsigned int"
36 .Fn ohash_qlookupi "struct ohash *h" "const char *start" "const char **pend"
37 .Ft "unsigned int"
38 .Fn ohash_qlookup "struct ohash *h" "const char *start"
39 .Sh DESCRIPTION
40 These functions are commonly used to simplify open hashing usage, and use
41 similar conventions.
42 They operate indifferently on NUL-terminated strings
43 .Po
44 by setting
45 .Fa *pend
46 =
47 .Dv NULL
48 .Pc
49 or memory ranges
50 .Po
51 delimited by
52 .Fa start
53 and
54 .Fa *pend
55 .Pc .
56 For NUL-terminated strings, as a side effect, those functions
57 set
58 .Fa *pend
59 to the terminating NUL byte.
60 .Pp
61 .Fn ohash_interval
62 is a simple hashing function that yields good results on common data sets.
63 .Pp
64 .Fn ohash_create_entry
65 can be used to create a new record with a given key.
66 In that case,
67 the alloc field of
68 .Fa info
69 should point to a
70 .Xr malloc 3 Ns -like
71 function to allocate the storage:
72 .Bd -literal -offset indent
73 p = (*info->alloc)(sz, info->data);
74 .Ed
75 .Pp
76 .Fn ohash_qlookupi
77 is a wrapper function that simply calls
78 .Fn ohash_interval
79 and
80 .Fn ohash_lookup_interval .
81 .Pp
82 .Fn ohash_qlookup
83 is a variation on
84 .Fn ohash_qlookupi
85 designed for NUL-terminated strings.
86 .Sh SEE ALSO
87 .Xr ohash_init 3
88 .Sh STANDARDS
89 Those functions are completely non-standard and should be avoided in
90 portable programs.
91 .Sh HISTORY
92 Those functions were designed and written for
93 .Ox
94 .Xr make 1
95 by Marc Espie in 1999.