It is only necessary to compact and terminate the array if we actually
modified anything.
void
cfg_del_match(const char *pattern_, ...)
{
+ bool matched = false;
char *pattern;
char **p;
if (!fnmatch(pattern, *p, 0)) {
free(*p);
*p = NULL;
+ matched = true;
}
}
- svec_compact(&cfg);
- svec_terminate(&cfg);
+ if (matched) {
+ svec_compact(&cfg);
+ svec_terminate(&cfg);
+ dirty = true;
+ }
free(pattern);
- dirty = true;
}
/* Fills 'svec' with all of the key-value pairs that have sections that