mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 16:04:49 +00:00
lib: remove entire data tree on yang_dnode_free()
For convenience, make yang_dnode_free() remove the entire data tree and not only the data node given as a parameter. Also, add a null-pointer check on nb_config_replace() before calling yang_dnode_free(). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
db452508bf
commit
e5dc8a44ee
@ -236,7 +236,8 @@ void nb_config_replace(struct nb_config *config_dst,
|
|||||||
config_dst->version = config_src->version;
|
config_dst->version = config_src->version;
|
||||||
|
|
||||||
/* Update dnode. */
|
/* Update dnode. */
|
||||||
yang_dnode_free(config_dst->dnode);
|
if (config_dst->dnode)
|
||||||
|
yang_dnode_free(config_dst->dnode);
|
||||||
if (preserve_source) {
|
if (preserve_source) {
|
||||||
config_dst->dnode = yang_dnode_dup(config_src->dnode);
|
config_dst->dnode = yang_dnode_dup(config_src->dnode);
|
||||||
} else {
|
} else {
|
||||||
|
@ -523,6 +523,8 @@ struct lyd_node *yang_dnode_dup(const struct lyd_node *dnode)
|
|||||||
|
|
||||||
void yang_dnode_free(struct lyd_node *dnode)
|
void yang_dnode_free(struct lyd_node *dnode)
|
||||||
{
|
{
|
||||||
|
while (dnode->parent)
|
||||||
|
dnode = dnode->parent;
|
||||||
lyd_free_withsiblings(dnode);
|
lyd_free_withsiblings(dnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user