| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: hash.h,v 1.19 2020/08/29 11:13:43 rillig Exp $ */ | | 1 | /* $NetBSD: hash.h,v 1.20 2020/09/01 21:00:15 rillig Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | | 4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. |
5 | * | | 5 | * |
6 | * This code is derived from software contributed to Berkeley by | | 6 | * This code is derived from software contributed to Berkeley by |
7 | * Adam de Boor. | | 7 | * Adam de Boor. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -104,43 +104,36 @@ typedef struct Hash_Table { | | | @@ -104,43 +104,36 @@ typedef struct Hash_Table { |
104 | } Hash_Table; | | 104 | } Hash_Table; |
105 | | | 105 | |
106 | /* | | 106 | /* |
107 | * The following structure is used by the searching routines | | 107 | * The following structure is used by the searching routines |
108 | * to record where we are in the search. | | 108 | * to record where we are in the search. |
109 | */ | | 109 | */ |
110 | | | 110 | |
111 | typedef struct Hash_Search { | | 111 | typedef struct Hash_Search { |
112 | Hash_Table *tablePtr; /* Table being searched. */ | | 112 | Hash_Table *tablePtr; /* Table being searched. */ |
113 | int nextIndex; /* Next bucket to check (after current). */ | | 113 | int nextIndex; /* Next bucket to check (after current). */ |
114 | Hash_Entry *hashEntryPtr; /* Next entry to check in current bucket. */ | | 114 | Hash_Entry *hashEntryPtr; /* Next entry to check in current bucket. */ |
115 | } Hash_Search; | | 115 | } Hash_Search; |
116 | | | 116 | |
117 | /* | | 117 | static inline void * MAKE_ATTR_UNUSED |
118 | * Macros. | | 118 | Hash_GetValue(Hash_Entry *h) |
119 | */ | | 119 | { |
120 | | | 120 | return h->clientPtr; |
121 | /* | | 121 | } |
122 | * void * Hash_GetValue(h) | | 122 | |
123 | * Hash_Entry *h; | | 123 | static inline void MAKE_ATTR_UNUSED |
124 | */ | | 124 | Hash_SetValue(Hash_Entry *h, void *datum) |
125 | | | 125 | { |
126 | #define Hash_GetValue(h) ((h)->clientPtr) | | 126 | h->clientPtr = datum; |
127 | | | 127 | } |
128 | /* | | | |
129 | * Hash_SetValue(h, val); | | | |
130 | * Hash_Entry *h; | | | |
131 | * char *val; | | | |
132 | */ | | | |
133 | | | | |
134 | #define Hash_SetValue(h, val) ((h)->clientPtr = (val)) | | | |
135 | | | 128 | |
136 | void Hash_InitTable(Hash_Table *, int); | | 129 | void Hash_InitTable(Hash_Table *, int); |
137 | void Hash_DeleteTable(Hash_Table *); | | 130 | void Hash_DeleteTable(Hash_Table *); |
138 | Hash_Entry *Hash_FindEntry(Hash_Table *, const char *); | | 131 | Hash_Entry *Hash_FindEntry(Hash_Table *, const char *); |
139 | Hash_Entry *Hash_CreateEntry(Hash_Table *, const char *, Boolean *); | | 132 | Hash_Entry *Hash_CreateEntry(Hash_Table *, const char *, Boolean *); |
140 | void Hash_DeleteEntry(Hash_Table *, Hash_Entry *); | | 133 | void Hash_DeleteEntry(Hash_Table *, Hash_Entry *); |
141 | Hash_Entry *Hash_EnumFirst(Hash_Table *, Hash_Search *); | | 134 | Hash_Entry *Hash_EnumFirst(Hash_Table *, Hash_Search *); |
142 | Hash_Entry *Hash_EnumNext(Hash_Search *); | | 135 | Hash_Entry *Hash_EnumNext(Hash_Search *); |
143 | void Hash_ForEach(Hash_Table *, void (*)(void *, void *), void *); | | 136 | void Hash_ForEach(Hash_Table *, void (*)(void *, void *), void *); |
144 | void Hash_DebugStats(Hash_Table *, const char *); | | 137 | void Hash_DebugStats(Hash_Table *, const char *); |
145 | | | 138 | |
146 | #endif /* MAKE_HASH_H */ | | 139 | #endif /* MAKE_HASH_H */ |