xref: /openbsd-src/share/man/man9/hashinit.9 (revision 7f32dcbfbc74f6304dd795fbaad35ded1fecea7c)
1.\"	$OpenBSD: hashinit.9,v 1.9 2016/09/24 18:59:04 tedu Exp $
2.\"
3.\" Copyright (c) 2001 Tobias Weingartner
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. The name of the author may not be used to endorse or promote products
15.\"    derived from this software without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.Dd $Mdocdate: September 24 2016 $
29.Dt HASHINIT 9
30.Os
31.Sh NAME
32.Nm hashinit ,
33.Nm hashfree
34.Nd kernel hashtable functions
35.Sh SYNOPSIS
36.In sys/systm.h
37.Ft void *
38.Fn hashinit "int num" "int type" "int flags" "u_long *mask"
39.Ft void
40.Fn hashfree "void *hash" "int num" "int type"
41.Sh DESCRIPTION
42The
43.Fn hashinit
44function is used to allocate a hashtable of a desired size given by the
45.Fa num
46argument.
47The
48.Fn hashinit
49function will round this number to the next power of two, and
50allocate and initialize the requested hashtable.
51The
52.Fa type
53and
54.Fa flags
55arguments are passed to the
56.Xr malloc 9
57function unchanged.
58The
59.Fa mask
60argument is used to pass back the mask for use with the allocated
61hashing table.
62.Pp
63The
64.Fn hashfree
65function causes memory allocated by the
66.Fn hashinit
67function to be released.
68The
69.Fa num
70and
71.Fa type
72arguments of related calls must match.
73.Sh RETURN VALUES
74The
75.Fn hashinit
76function returns a pointer to the allocated and initialized hash table.
77.Sh SEE ALSO
78.Xr free 9 ,
79.Xr malloc 9
80.Sh LIMITATIONS
81The
82.Fn hashinit
83function currently only allocates hash tables with LIST bucket pointers
84at this time.
85Future enhancements to allocate QUEUE bucket pointers may be warranted.
86This may necessitate an API change to accommodate.
87.Sh HISTORY
88The
89.Nm
90function first appeared in
91.Bx 4.4 .
92