hash.c (138434) | hash.c (138435) |
---|---|
1/* 2 * Copyright (c) 1988, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1988, 1989 by Adam de Boor 5 * Copyright (c) 1989 by Berkeley Softworks 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 26 unchanged lines hidden (view full) --- 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)hash.c 8.1 (Berkeley) 6/6/93 40 */ 41 42#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1988, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1988, 1989 by Adam de Boor 5 * Copyright (c) 1989 by Berkeley Softworks 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 26 unchanged lines hidden (view full) --- 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)hash.c 8.1 (Berkeley) 6/6/93 40 */ 41 42#include <sys/cdefs.h> |
43__FBSDID("$FreeBSD: head/usr.bin/make/hash.c 138434 2004-12-06 08:52:02Z harti $"); | 43__FBSDID("$FreeBSD: head/usr.bin/make/hash.c 138435 2004-12-06 08:56:30Z harti $"); |
44 45/* hash.c -- 46 * 47 * This module contains routines to manipulate a hash table. 48 * See hash.h for a definition of the structure of the hash 49 * table. Hash tables grow automatically as the amount of 50 * information increases. 51 */ --- 107 unchanged lines hidden (view full) --- 159 * present, NULL is returned. 160 * 161 * Side Effects: 162 * None. 163 * 164 *--------------------------------------------------------- 165 */ 166Hash_Entry * | 44 45/* hash.c -- 46 * 47 * This module contains routines to manipulate a hash table. 48 * See hash.h for a definition of the structure of the hash 49 * table. Hash tables grow automatically as the amount of 50 * information increases. 51 */ --- 107 unchanged lines hidden (view full) --- 159 * present, NULL is returned. 160 * 161 * Side Effects: 162 * None. 163 * 164 *--------------------------------------------------------- 165 */ 166Hash_Entry * |
167Hash_FindEntry(Hash_Table *t, char *key) | 167Hash_FindEntry(const Hash_Table *t, const char *key) |
168{ 169 Hash_Entry *e; 170 unsigned h; | 168{ 169 Hash_Entry *e; 170 unsigned h; |
171 char *p; | 171 const char *p; |
172 173 for (h = 0, p = key; *p;) 174 h = (h << 5) - h + *p++; 175 p = key; 176 for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) 177 if (e->namehash == h && strcmp(e->name, p) == 0) 178 return (e); 179 return (NULL); --- 13 unchanged lines hidden (view full) --- 193 * new entry was created, and FALSE if an entry already existed 194 * with the given key. 195 * 196 * Side Effects: 197 * Memory may be allocated, and the hash buckets may be modified. 198 *--------------------------------------------------------- 199 */ 200Hash_Entry * | 172 173 for (h = 0, p = key; *p;) 174 h = (h << 5) - h + *p++; 175 p = key; 176 for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) 177 if (e->namehash == h && strcmp(e->name, p) == 0) 178 return (e); 179 return (NULL); --- 13 unchanged lines hidden (view full) --- 193 * new entry was created, and FALSE if an entry already existed 194 * with the given key. 195 * 196 * Side Effects: 197 * Memory may be allocated, and the hash buckets may be modified. 198 *--------------------------------------------------------- 199 */ 200Hash_Entry * |
201Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr) | 201Hash_CreateEntry(Hash_Table *t, const char *key, Boolean *newPtr) |
202{ 203 Hash_Entry *e; 204 unsigned int h; | 202{ 203 Hash_Entry *e; 204 unsigned int h; |
205 char *p; | 205 const char *p; |
206 int keylen; 207 struct Hash_Entry **hp; 208 209 /* 210 * Hash the key. As a side effect, save the length (strlen) of the 211 * key in case we need to create the entry. 212 */ 213 for (h = 0, p = key; *p;) --- 182 unchanged lines hidden --- | 206 int keylen; 207 struct Hash_Entry **hp; 208 209 /* 210 * Hash the key. As a side effect, save the length (strlen) of the 211 * key in case we need to create the entry. 212 */ 213 for (h = 0, p = key; *p;) --- 182 unchanged lines hidden --- |