| 168 | } |
| 169 | |
| 170 | int msRemoveHashTable(hashTableObj *table, const char *key) |
| 171 | { |
| 172 | struct hashObj *tp; |
| 173 | struct hashObj *prev_tp=NULL; |
| 174 | int status = MS_FAILURE; |
| 175 | |
| 176 | if (!table || !key) { |
| 177 | msSetError(MS_HASHERR, "No hash table", "msRemoveHashTable"); |
| 178 | return MS_FAILURE; |
| 179 | } |
| 180 | |
| 181 | tp=table->items[hash(key)]; |
| 182 | if (!tp) { |
| 183 | msSetError(MS_HASHERR, "No such hash entry", "msRemoveHashTable"); |
| 184 | return MS_FAILURE; |
| 185 | } |
| 186 | |
| 187 | prev_tp = NULL; |
| 188 | while (tp != NULL) { |
| 189 | if (strcasecmp(key, tp->key) == 0) { |
| 190 | status = MS_SUCCESS; |
| 191 | if (prev_tp) { |
| 192 | prev_tp->next = tp->next; |
| 193 | free(tp); |
| 194 | break; |
| 195 | } |
| 196 | else { |
| 197 | table->items[hash(key)] = tp->next; |
| 198 | free(tp); |
| 199 | break; |
| 200 | } |
| 201 | } |
| 202 | prev_tp = tp; |
| 203 | tp = tp->next; |
| 204 | } |
| 205 | |
| 206 | if (status == MS_SUCCESS) |
| 207 | table->numitems--; |
| 208 | |
| 209 | return status; |
| 210 | } |
| 211 | |
| 212 | const char *msFirstKeyFromHashTable( hashTableObj *table ) |
| 213 | { |
no test coverage detected