1*7f32dcbfStedu.\" $OpenBSD: hashinit.9,v 1.9 2016/09/24 18:59:04 tedu Exp $ 2611091d8Sweingart.\" 3611091d8Sweingart.\" Copyright (c) 2001 Tobias Weingartner 4611091d8Sweingart.\" All rights reserved. 5611091d8Sweingart.\" 6611091d8Sweingart.\" Redistribution and use in source and binary forms, with or without 7611091d8Sweingart.\" modification, are permitted provided that the following conditions 8611091d8Sweingart.\" are met: 9611091d8Sweingart.\" 1. Redistributions of source code must retain the above copyright 10611091d8Sweingart.\" notice, this list of conditions and the following disclaimer. 11611091d8Sweingart.\" 2. Redistributions in binary form must reproduce the above copyright 12611091d8Sweingart.\" notice, this list of conditions and the following disclaimer in the 13611091d8Sweingart.\" documentation and/or other materials provided with the distribution. 14611091d8Sweingart.\" 3. The name of the author may not be used to endorse or promote products 15611091d8Sweingart.\" derived from this software without specific prior written permission. 16611091d8Sweingart.\" 17611091d8Sweingart.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18611091d8Sweingart.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19611091d8Sweingart.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20611091d8Sweingart.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21611091d8Sweingart.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22611091d8Sweingart.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23611091d8Sweingart.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24611091d8Sweingart.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25611091d8Sweingart.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26611091d8Sweingart.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27611091d8Sweingart.\" 2854f18723Stedu.Dd $Mdocdate: September 24 2016 $ 29611091d8Sweingart.Dt HASHINIT 9 30611091d8Sweingart.Os 31611091d8Sweingart.Sh NAME 3254f18723Stedu.Nm hashinit , 3354f18723Stedu.Nm hashfree 34611091d8Sweingart.Nd kernel hashtable functions 35611091d8Sweingart.Sh SYNOPSIS 36dddd2645Sschwarze.In sys/systm.h 37611091d8Sweingart.Ft void * 38611091d8Sweingart.Fn hashinit "int num" "int type" "int flags" "u_long *mask" 3954f18723Stedu.Ft void 4054f18723Stedu.Fn hashfree "void *hash" "int num" "int type" 41611091d8Sweingart.Sh DESCRIPTION 42611091d8SweingartThe 43611091d8Sweingart.Fn hashinit 44611091d8Sweingartfunction is used to allocate a hashtable of a desired size given by the 45611091d8Sweingart.Fa num 46611091d8Sweingartargument. 47611091d8SweingartThe 48611091d8Sweingart.Fn hashinit 49611091d8Sweingartfunction will round this number to the next power of two, and 50611091d8Sweingartallocate and initialize the requested hashtable. 51611091d8SweingartThe 52611091d8Sweingart.Fa type 53611091d8Sweingartand 54611091d8Sweingart.Fa flags 55611091d8Sweingartarguments are passed to the 56611091d8Sweingart.Xr malloc 9 57611091d8Sweingartfunction unchanged. 58611091d8SweingartThe 59611091d8Sweingart.Fa mask 60611091d8Sweingartargument is used to pass back the mask for use with the allocated 61611091d8Sweingarthashing table. 62*7f32dcbfStedu.Pp 63*7f32dcbfSteduThe 64*7f32dcbfStedu.Fn hashfree 65*7f32dcbfStedufunction causes memory allocated by the 66*7f32dcbfStedu.Fn hashinit 67*7f32dcbfStedufunction to be released. 68*7f32dcbfSteduThe 69*7f32dcbfStedu.Fa num 70*7f32dcbfSteduand 71*7f32dcbfStedu.Fa type 72*7f32dcbfSteduarguments of related calls must match. 73611091d8Sweingart.Sh RETURN VALUES 74611091d8SweingartThe 75611091d8Sweingart.Fn hashinit 76611091d8Sweingartfunction returns a pointer to the allocated and initialized hash table. 77611091d8Sweingart.Sh SEE ALSO 788a7802e4Sjmc.Xr free 9 , 798a7802e4Sjmc.Xr malloc 9 80611091d8Sweingart.Sh LIMITATIONS 81611091d8SweingartThe 82611091d8Sweingart.Fn hashinit 83611091d8Sweingartfunction currently only allocates hash tables with LIST bucket pointers 84611091d8Sweingartat this time. 85611091d8SweingartFuture enhancements to allocate QUEUE bucket pointers may be warranted. 86611091d8SweingartThis may necessitate an API change to accommodate. 87611091d8Sweingart.Sh HISTORY 88611091d8SweingartThe 89611091d8Sweingart.Nm 90611091d8Sweingartfunction first appeared in 91611091d8Sweingart.Bx 4.4 . 92