mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm-config: Implement dm_config_remove_node.
This commit is contained in:
parent
8bc9966763
commit
de2c5ab2ac
@ -1879,6 +1879,7 @@ int dm_config_write_one_node_out(const struct dm_config_node *cn, const struct d
|
||||
|
||||
struct dm_config_node *dm_config_find_node(const struct dm_config_node *cn, const char *path);
|
||||
int dm_config_has_node(const struct dm_config_node *cn, const char *path);
|
||||
int dm_config_remove_node(struct dm_config_node *parent, struct dm_config_node *remove);
|
||||
const char *dm_config_find_str(const struct dm_config_node *cn, const char *path, const char *fail);
|
||||
const char *dm_config_find_str_allow_empty(const struct dm_config_node *cn, const char *path, const char *fail);
|
||||
int dm_config_find_int(const struct dm_config_node *cn, const char *path, int fail);
|
||||
|
@ -1380,3 +1380,20 @@ struct dm_config_tree *dm_config_flatten(struct dm_config_tree *cft)
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int dm_config_remove_node(struct dm_config_node *parent, struct dm_config_node *remove)
|
||||
{
|
||||
struct dm_config_node *cn = parent->child, *last = NULL;
|
||||
while (cn) {
|
||||
if (cn == remove) {
|
||||
if (last)
|
||||
last->sib = cn->sib;
|
||||
else
|
||||
parent->child = cn->sib;
|
||||
return 1;
|
||||
}
|
||||
last = cn;
|
||||
cn = cn->sib;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user