MCPcopy Index your code
hub / github.com/MapServer/MapServer / msInsertHashTable

Function msInsertHashTable

maphash.c:121–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121struct 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
155char *msLookupHashTable(hashTableObj *table, const char *key)
156{

Callers 15

msSLDApplySLDFunction · 0.85
msSLDParseNamedLayerFunction · 0.85
msSetWMSParamStringFunction · 0.85
msSetWMSParamIntFunction · 0.85
mainFunction · 0.85
msCopyHashTableFunction · 0.85
loadHashTableFunction · 0.85
layerSubstituteStringFunction · 0.85

Calls 4

msSetErrorFunction · 0.85
hashFunction · 0.85
strcasecmpFunction · 0.85
msStrdupFunction · 0.85

Tested by

no test coverage detected