From 9e7af669053aae80bb0b0e03916cc4637e444d10 Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Tue, 31 Oct 2023 13:27:56 +0200 Subject: [PATCH] tree data UPDATE add ability to duplicate tree with priv pointers Signed-off-by: Igor Ryzhov --- src/tree_data.c | 3 +++ src/tree_data.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/tree_data.c b/src/tree_data.c index cc1ad2ee3..0fdf662df 100644 --- a/src/tree_data.c +++ b/src/tree_data.c @@ -1738,6 +1738,9 @@ lyd_dup_r(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_ } else { dup->flags = (node->flags & (LYD_DEFAULT | LYD_EXT)) | LYD_NEW; } + if (options & LYD_DUP_WITH_PRIV) { + dup->priv = node->priv; + } if (trg_ctx == LYD_CTX(node)) { dup->schema = node->schema; } else { diff --git a/src/tree_data.h b/src/tree_data.h index eb7f766de..fd8137c40 100644 --- a/src/tree_data.h +++ b/src/tree_data.h @@ -1962,6 +1962,8 @@ LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const str #define LYD_DUP_WITH_FLAGS 0x08 /**< Also copy any data node flags. That will cause the duplicated data to preserve its validation/default node state. */ #define LYD_DUP_NO_EXT 0x10 /**< Do not duplicate nodes with the ::LYD_EXT flag (nested extension instance data). */ +#define LYD_DUP_WITH_PRIV 0x20 /**< Also copy data node private pointer. Only the pointer is copied, it still points + to the same data. */ /** @} dupoptions */