@@ -83,6 +83,10 @@ SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const vo
83
83
SDL_HashItem * item ;
84
84
const Uint32 hash = calc_hash (table , key );
85
85
86
+ if (!table ) {
87
+ return SDL_FALSE ;
88
+ }
89
+
86
90
if ( (!table -> stackable ) && (SDL_FindInHashTable (table , key , NULL )) ) {
87
91
return SDL_FALSE ;
88
92
}
@@ -107,6 +111,10 @@ SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const
107
111
void * data = table -> data ;
108
112
SDL_HashItem * i ;
109
113
114
+ if (!table ) {
115
+ return SDL_FALSE ;
116
+ }
117
+
110
118
for (i = table -> table [hash ]; i ; i = i -> next ) {
111
119
if (table -> keymatch (key , i -> key , data )) {
112
120
if (_value ) {
@@ -126,6 +134,10 @@ SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key)
126
134
SDL_HashItem * prev = NULL ;
127
135
void * data = table -> data ;
128
136
137
+ if (!table ) {
138
+ return SDL_FALSE ;
139
+ }
140
+
129
141
for (item = table -> table [hash ]; item ; item = item -> next ) {
130
142
if (table -> keymatch (key , item -> key , data )) {
131
143
if (prev ) {
@@ -134,7 +146,9 @@ SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key)
134
146
table -> table [hash ] = item -> next ;
135
147
}
136
148
137
- table -> nuke (item -> key , item -> value , data );
149
+ if (table -> nuke ) {
150
+ table -> nuke (item -> key , item -> value , data );
151
+ }
138
152
SDL_free (item );
139
153
return SDL_TRUE ;
140
154
}
@@ -149,6 +163,10 @@ SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, co
149
163
{
150
164
SDL_HashItem * item = * iter ? ((SDL_HashItem * ) * iter )-> next : table -> table [calc_hash (table , key )];
151
165
166
+ if (!table ) {
167
+ return SDL_FALSE ;
168
+ }
169
+
152
170
while (item ) {
153
171
if (table -> keymatch (key , item -> key , table -> data )) {
154
172
* _value = item -> value ;
@@ -169,6 +187,10 @@ SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, con
169
187
SDL_HashItem * item = (SDL_HashItem * ) * iter ;
170
188
Uint32 idx = 0 ;
171
189
190
+ if (!table ) {
191
+ return SDL_FALSE ;
192
+ }
193
+
172
194
if (item ) {
173
195
const SDL_HashItem * orig = item ;
174
196
item = item -> next ;
@@ -219,7 +241,9 @@ void SDL_DestroyHashTable(SDL_HashTable *table)
219
241
SDL_HashItem * item = table -> table [i ];
220
242
while (item ) {
221
243
SDL_HashItem * next = item -> next ;
222
- table -> nuke (item -> key , item -> value , data );
244
+ if (table -> nuke ) {
245
+ table -> nuke (item -> key , item -> value , data );
246
+ }
223
247
SDL_free (item );
224
248
item = next ;
225
249
}
0 commit comments