+ /**
+ * First scan through to see if we're doing a replacement of
+ * an existing key
+ */
+ ptr = NULL;
+ for (scan=WC->vars; scan!=NULL; scan=scan->next) {
+ if (!strcasecmp(scan->wcs_key, keyname)) {
+ ptr = scan;
+ if (ptr->wcs_value != NULL)
+ free(ptr->wcs_value);
+ }
+ }
+
+ /** Otherwise allocate a new one */
+ if (ptr == NULL) {
+ ptr = (struct wcsubst *) malloc(sizeof(struct wcsubst));
+ safestrncpy(ptr->wcs_key, keyname, sizeof ptr->wcs_key);
+ ptr->next = WC->vars;
+ WC->vars = ptr;
+ }
+ ptr->wcs_value = NULL;