| 119 | } |
| 120 | |
| 121 | struct hashObj *msInsertHashTable(hashTableObj *table, |
| 122 | const char *key, const char *value) |
| 123 | { |
| 124 | struct hashObj *tp; |
| 125 | unsigned hashval; |
| 126 | |
| 127 | if (!table || !key || !value) { |
| 128 | msSetError(MS_HASHERR, "Invalid hash table or key", |
| 129 | "msInsertHashTable"); |
| 130 | return NULL; |
| 131 | } |
| 132 | |
| 133 | for (tp=table->items[hash(key)]; tp!=NULL; tp=tp->next) |
| 134 | if(strcasecmp(key, tp->key) == 0) |
| 135 | break; |
| 136 | |
| 137 | if (tp == NULL) { /* not found */ |
| 138 | tp = (struct hashObj *) malloc(sizeof(*tp)); |
| 139 | MS_CHECK_ALLOC(tp, sizeof(*tp), NULL); |
| 140 | tp->key = msStrdup(key); |
| 141 | hashval = hash(key); |
| 142 | tp->next = table->items[hashval]; |
| 143 | table->items[hashval] = tp; |
| 144 | table->numitems++; |
| 145 | } else { |
| 146 | free(tp->data); |
| 147 | } |
| 148 | |
| 149 | if ((tp->data = msStrdup(value)) == NULL) |
| 150 | return NULL; |
| 151 | |
| 152 | return tp; |
| 153 | } |
| 154 | |
| 155 | char *msLookupHashTable(hashTableObj *table, const char *key) |
| 156 | { |
no test coverage detected