2 Unix SMB/Netbios implementation.
5 Copyright (C) Ying Chen 2000.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #define MAX_HASH_TABLE_SIZE 32768
26 #define HASH_TABLE_INCREMENT 2
28 typedef int (*compare_function
)(char *, char *);
29 typedef int (*hash_function
)(int, char *);
32 * lru_link: links the node to the LRU list.
33 * hash_elem: the pointer to the element that is tied onto the link.
35 typedef struct lru_node
{
41 * bucket_link: link the hash element to the bucket chain that it belongs to.
42 * lru_link: this element ties the hash element to the lru list.
43 * bucket: a pointer to the hash bucket that this element belongs to.
44 * value: a pointer to the hash element content. It can be anything.
45 * key: stores the string key. The hash_element is always allocated with
46 * more memory space than the structure shown below to accomodate the space
47 * used for the whole string. But the memory is always appended at the
48 * end of the structure, so keep "key" at the end of the structure.
51 typedef struct hash_element
{
52 ubi_dlNode bucket_link
;
60 * buckets: a list of buckets, implemented as a dLinkList.
61 * lru_chain: the lru list of all the hash elements.
62 * num_elements: the # of elements in the hash table.
63 * size: the hash table size.
64 * comp_func: the compare function used during hash key comparisons.
67 typedef struct hash_table
{
72 compare_function comp_func
;