forked from github/server
turns out that set_param with null should remove the setting.
This commit is contained in:
parent
eb5c912805
commit
04bbec2b89
|
@ -1122,8 +1122,15 @@ void set_param(struct param **p, const char *key, const char *data)
|
|||
while (*p != NULL) {
|
||||
int cmp = strcmp((*p)->name, key);
|
||||
if (cmp == 0) {
|
||||
free((*p)->data);
|
||||
(*p)->data = _strdup(data);
|
||||
par = *p;
|
||||
free(par->data);
|
||||
if (data) {
|
||||
par->data = _strdup(data);
|
||||
}
|
||||
else {
|
||||
*p = par->next;
|
||||
free(par);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (cmp > 0) {
|
||||
|
|
|
@ -71,6 +71,8 @@ static void test_get_set_param(CuTest * tc)
|
|||
set_param(&par, "bar", "foo");
|
||||
CuAssertStrEquals(tc, "bar", get_param(par, "foo"));
|
||||
CuAssertStrEquals(tc, "foo", get_param(par, "bar"));
|
||||
set_param(&par, "bar", NULL);
|
||||
CuAssertPtrEquals(tc, NULL, (void *)get_param(par, "bar"));
|
||||
}
|
||||
|
||||
static void test_param_int(CuTest * tc)
|
||||
|
|
Loading…
Reference in New Issue