Fix deleting items from string lists.
This commit is contained in:
parent
64d1dd9da0
commit
ebcfd49e9c
@ -114,24 +114,24 @@ bool rc_strlist_delete (char ***list, const char *item)
|
|||||||
{
|
{
|
||||||
char **lst = *list;
|
char **lst = *list;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
bool retval = false;
|
|
||||||
|
|
||||||
if (!lst || ! item)
|
if (!lst || ! item)
|
||||||
return (false);
|
return (false);
|
||||||
|
|
||||||
while (lst[i])
|
while (lst[i]) {
|
||||||
if (! strcmp (lst[i], item)) {
|
if (strcmp (lst[i], item) == 0) {
|
||||||
free (lst[i]);
|
free (lst[i]);
|
||||||
retval = true;
|
|
||||||
do {
|
do {
|
||||||
lst[i] = lst[i + 1];
|
lst[i] = lst[i + 1];
|
||||||
i++;
|
i++;
|
||||||
} while (lst[i]);
|
} while (lst[i]);
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! retval)
|
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (retval);
|
return (false);
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_strlist_delete)
|
librc_hidden_def(rc_strlist_delete)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user