da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.fp 5 CW
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.de Af
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin..
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.de aF
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.ie \\$3 .ft \\$1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.el \{\
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.ds ;G \&
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.nr ;G \\n(.f
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin\\*(;G
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.ft \\n(;G \}
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin..
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.de L
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin..
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.de LR
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin..
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.de RL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin..
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.de EX \" start example
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.ta 1i 2i 3i 4i 5i 6i
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.PP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.PD 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.ft 5
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.nf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin..
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.de EE \" end example
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.fi
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.ft
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.PD
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.PP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin..
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TH HASH 3
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.SH NAME
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulknerhash \- hash table support (obsolete: use \fBcdt\fP instead)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.SH SYNOPSIS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "#include <hash.h>"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.SH DESCRIPTION
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I hash
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinroutines manipulate collections of dynamic, scoped hash tables.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.PP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinA hash table provides an association between a
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I key
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinand its
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR value .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinA
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I key
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis a sequence of
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L char
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinelements and a
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis a user supplied pointer to the value.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinEach hash table has a dynamic number of slots,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chineach pointing to the head of a forward linked
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR "collision chain" .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.PP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinHashing occurs as follows:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968china
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I "hash function"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintakes a
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I key
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinas an argument and returns a non-negative index.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe index modulo the table size produces a
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinslot that points to a
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR "collision chain" .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe collision chain is sequentially searched until a match is found for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR key .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe hash tables are automatically resized as new entries are added.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.PP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinEach hash table has one key type.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe default key type is a pointer to a null-terminated string.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe alternate key type is a pointer to a fixed length byte buffer,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chindeclared for a given table by the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L hashalloc()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinfunction described below.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.PP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinHash table information is partitioned into two parts for efficient scoping.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I root
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpart contains fixed information that is shared among a set of related
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinhash tables.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe remaining information is maintained on a per-table basis.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.PP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThese basic types are defined in the header file
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.B hash.h
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(alternate names are listed in parenthesis):
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_table_t (HASHTABLE)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe per-table information.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe readonly public elements are:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "int buckets"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe number of table entries.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "char* name"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe hash table name.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "root"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe root information.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe public elements are:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "int root->accesses"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe number of lookups.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "int root->collisions"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe number of lookup collisions.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_table_t* scope"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe table that this scope covers,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinif the table is not a scope.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "int size"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe current hash table size.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_bucket_t (HASHBUCKET)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinA collision chain hash bucket.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe public structure elements are:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "char* hashname(Hash_bucket_t*)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinReturns a pointer to the hash bucket key given the bucket pointer.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "char* value"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe value associated with the key.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_header_t (HASHHEADER)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe hash bucket header that must be the first element in all user defined
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinbuckets.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_VALUE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmay not be used with user defined buckets.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_position_t (HASHPOSITION)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinStores the hash table position for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR hashscan .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe public elements are:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_bucket_t* bucket"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe current hash bucket pointer.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.PP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe routines are:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_table_t* hashalloc(Hash_table_t* ref, int op, ...)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinCreates a new hash table and returns a pointer to the table.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR malloc (3)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis used to allocate space for the table.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis returned if the table cannot be created.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L ref
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis a pointer to a reference hash table that provides
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chindefault values for unspecified information.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe new hash table and
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L ref
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinshare the same root information.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L ref
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthen new root information is created for the new table.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe remaining arguments appear in
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I op-arg
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpairs, followed by a final
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinargument.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I op-arg
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpairs are:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_alloc, (char(*)()) alloc"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L alloc
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis a function that is called to process
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L Hash_bucket_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinassignments.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe single argument is
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "char* value"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinand the processed
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L char*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinvalue is returned.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_clear, int flags"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L flags
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinare the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L ref
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinflags to be cleared in the new hash table.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSee
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_set
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinbelow.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_compare, (int(*)()) compare"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSpecifies an alternate
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I key
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chincomparison function.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe arguments and return value for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L compare
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinare the same as for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR strncmp (3)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_namesize
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis specified and
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR strcmp (3)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinotherwise.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe first argument is the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I key
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinfrom the current hash bucket on the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I "collision chain"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinand the second argument is the user supplied
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR key .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_free, (int(*)()) free"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L free
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis a function that is called when a hash bucket is freed.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_BUCKET
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinwas set in
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L hashalloc
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthen the hash bucket pointer is passed, otherwise the bucket
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpointer is passed.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_hash, (int(*)()) hash"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSpecifies an alternate
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I key
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinhash function.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinA
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L char*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinkey argument (and, if
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_namesize
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis specified, an
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L int
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinkey size argument) is passed to
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR hash .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe return value must be a non-negative
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR int .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_meanchain, int meanchain"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSpecifies the mean collision chain length.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe hash table is automatically resized when this value is exceeded.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe default mean chain length is 2.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_name, char* name"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinAssociates
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinwith the hash table.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinUsed by
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR hashdump) .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_namesize, int namesize"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe fixed size in bytes for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I keys
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinin the table.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L namesize
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis 0 (the default) then the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I keys
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinare interpreted as null-terminated strings.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_set, int flags"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinChanges the hash table flags by
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR or ing
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR flags .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe flags, which may be
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR or ed
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintogether, are:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_ALLOCATE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinKeys for new hash table entries are to be copied to data areas obtained from
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR malloc (3).
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_FIXED
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinFixes the hash table size, disabling any automatic table resizing.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_SCOPE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe new hash table is a scope that is to be pushed on top of
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR ref .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L ref
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmust be
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RL non- NULL .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_va_list, va_list ap"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L ap
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis a
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L va_list
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinvariable argument list pointer
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(see
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR <stdarg.h> ).
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_table_t* hashfree(Hash_table_t* tab)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe hash table
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L tab
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis freed.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe scope covered table pointer is returned,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L tab
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis not a scope.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "char* hashlook(Hash_table_t* tab, char* name, int flags, char* value)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinOperates on the key
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinin the hash table
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L tab
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinaccording to
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L flags
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinand
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR value .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinA
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L Hash_bucket_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpointer is returned unless otherwise noted.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThere are three basic lookup operations:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_CREATE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis entered into the top level scope if it does not already exist.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinalso appears in a lower scope and
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_ALLOC
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis set for the table then the new bucket will share the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinfield value with the lower scope.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_DELETE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis deleted from the top level scope if it exists.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis returned.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_LOOKUP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe scopes are searched in order from top to bottom for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe bucket pointer for the first occurrence is returned.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis returned if
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis not found.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe basic operations may be qualified by the following
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(the qualifiers are restricted to the basic operations in
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthe parenthesized list):
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_BUCKET (HASH_CREATE,HASH_DELETE,HASH_LOOKUP)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis a pointer to a bucket that has already been entered into the table.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_FIXED (HASH_CREATE)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis taken to be the size of the hash bucket to be created for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinin the top level scope.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe minimum bucket size is silently restricted to
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR sizeof(Hash_header_t) .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_INSTALL (HASH_CREATE)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis a pointer to a bucket that has not been entered into the table.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_NOSCOPE (HASH_LOOKUP)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe lookup is restricted to the top level scope.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_OPAQUE (HASH_CREATE,HASH_DELETE)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSets
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L (HASH_CREATE)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinor clears
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L (HASH_DELETE)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthe
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I opaque
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinproperty for the bucket.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinAn opaque bucket is not visible in lower scopes.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_SCOPE (HASH_CREATE,HASH_DELETE)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinAll scopes are searched for the bucket.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf the bucket is not found for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_CREATE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthen a new bucket is created in the lowest scope.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "HASH_VALUE (HASH_CREATE,HASH_LOOKUP)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinFor
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_CREATE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthe bucket
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinfield is set to
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinand the bucket
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinvalue is returned.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinFor
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_LOOKUP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthe bucket
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinfield is returned,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinif the bucket is not found.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.RE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthen the name from the most recent
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L hashlook()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis used, avoiding recomputation of some internal parameters.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "char* hashget(Hash_table_t* tab, char* name)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinReturns the value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinassociated with the key
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinin the hash table
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR tab .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthen the name from the most recent
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L hashget()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis used, avoiding recomputation of some internal parameters.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis returned if
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis not in the table.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinAll scope covered tables are searched.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_bucket_t* hashlast(Hash_table_t* tab)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinReturns a pointer to the most recent hash bucket for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR tab .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe value is set by
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR hashlook() ,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L hashscan()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinand
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR hashwalk() .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "char* hashput(Hash_table_t* tab, char* name, char* value)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSet the value of the key
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinto
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinin the top level scope of the hash table
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR tab .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis entered into the top level scope if necessary.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe (possibly re-allocated) key name pointer is returned
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(see
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR HASH_ALLOCATE ).
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis 0 then the most recent lookup
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinto
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L hashlook()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinor
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L hashget()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis used.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThis eliminates a re-hash and re-lookup of
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR name .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "int hashwalk(Hash_table_t* tab, int flags, (int(*)()) walker, char* handle)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe function
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L walker
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis applied to each entry (not covered by a scope starting at
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR tab )
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinin the hash table
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR tab .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L flags
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_NOSCOPE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthen only the top level hash table is used, otherwise the walk includes
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinall scope covered tables.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L walker
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis called with
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L char*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I key
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinas the first argument,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L char*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinas the second argument, and
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L char*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I handle
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinas the third argument.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I handle
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmay be
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR 0 .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe walk terminates after the last entry or when
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L walker
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinreturns a negative value.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe return value of the last call to
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L walker
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis returned.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinOnly one walk may be active within a collection of scoped tables.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_position_t* hashscan(Hash_table_t* tab, int flags)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinReturns a
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L Hash_position_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpointer for a sequential scan on the hash table
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR tab .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L flags
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_NOSCOPE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthen only the top level hash table is used, otherwise the scan includes
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinall scope covered tables.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinOnly one scan may be active within a collection of scoped tables.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L hashdone()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmust be called to terminate the scan.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis returned on error.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "Hash_bucket_t* hashnext(Hash_position_t* pos)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinReturnes a pointer to the next bucket in the sequential scan set up by
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L hashscan()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinon
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR pos .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf no elements remain then
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis returned.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "void hashdone(Hash_position_t* pos)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinCompletes a scan initiated by
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L hashscan()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinon
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR pos .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "int hashset(Hash_table_t* tab, int flags)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSets the flags for the hash table
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L tab
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinby
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.IR or ing
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR flags .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinOnly
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_ALLOCATE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinand
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_FIXED
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmay be set.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "int hashclear(Hash_table_t* tab, int flags)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinClears the flags for the hash table
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L tab
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinby masking out
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.LR flags .
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinOnly
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_ALLOCATE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinand
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_FIXED
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmay be cleared.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "void hashdump(Hash_table_t* tab, int flags)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinDumps hash table accounting info to standard error.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L tab
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L NULL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthen all allocated hash tables are dumped, otherwise only information on
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L tab
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis dumped.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinIf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L flags
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L HASH_BUCKET
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthen the hash bucket
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.I key-value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpairs for each collision chain are also dumped.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "void hashsize(Hash_table_t* tab, int size)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinChanges the size of the hash table
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L tab
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinto
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L size
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinwhere
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L size
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmust be a power of 2.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinExplicit calls to this routine are not necessary as hash tables
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinare automatically resized.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "int strhash(char* name)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinHashes the null terminated character string
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinusing a linear congruent pseudo-random number generator algorithm
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinand returns a non-negative
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L int
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinhash value.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "int memhash(char* buf, int siz)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinHashes the buffer
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L buf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinof
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L siz
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinbytes using a linear congruent pseudo-random number generator algorithm
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinand returns a non-negative
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L int
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinhash value.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "long strsum(char* name, long sum)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinReturns a running 31-bit checksum of the string
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinwhere
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L sum
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinon the first call and
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthe return value from a previous
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L memsum
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinor
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L strsum
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chincall otherwise.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe checksum value is consistent across all implementations.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.TP
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L "long memsum(char* buf, int siz, long sum)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinReturns a running 31-bit checksum of buffer
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L buf
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinof
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L siz
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinbytes where
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L sum
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinis
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinon the first call and
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinthe return value from a previous
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L memsum
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinor
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.L strsum
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chincall otherwise.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe checksum value is consistent across all implementations.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin.SH "SEE ALSO"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinsum(1)