schema CHANGE remove lysc_node_set_private() which duplicates lysc_set_private()
Duplication in the API, lysc_node_set_private() was limited to lysc_node
only while lysc_set_private() handles also RPCs or Notifications.
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 4d1aba3..d5d672c 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -799,14 +799,45 @@
}
API LY_ERR
-lysc_node_set_private(const struct lysc_node *node, void *priv, void **prev_priv_p)
+lysc_set_private(const struct lysc_node *node, void *priv, void **prev_priv_p)
{
+ struct lysc_action *act;
+ struct lysc_notif *notif;
+
LY_CHECK_ARG_RET(NULL, node, LY_EINVAL);
- if (prev_priv_p) {
- *prev_priv_p = node->priv;
+ switch (node->nodetype) {
+ case LYS_CONTAINER:
+ case LYS_CHOICE:
+ case LYS_CASE:
+ case LYS_LEAF:
+ case LYS_LEAFLIST:
+ case LYS_LIST:
+ case LYS_ANYXML:
+ case LYS_ANYDATA:
+ if (prev_priv_p) {
+ *prev_priv_p = node->priv;
+ }
+ ((struct lysc_node *)node)->priv = priv;
+ break;
+ case LYS_RPC:
+ case LYS_ACTION:
+ act = (struct lysc_action *)node;
+ if (prev_priv_p) {
+ *prev_priv_p = act->priv;
+ }
+ act->priv = priv;
+ break;
+ case LYS_NOTIF:
+ notif = (struct lysc_notif *)node;
+ if (prev_priv_p) {
+ *prev_priv_p = notif->priv;
+ }
+ notif->priv = priv;
+ break;
+ default:
+ return LY_EINVAL;
}
- ((struct lysc_node *)node)->priv = priv;
return LY_SUCCESS;
}
diff --git a/src/tree_schema.h b/src/tree_schema.h
index 2fdbc6c..8f16508 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -1746,11 +1746,11 @@
*
* @param[in] node Node, whose private field will be assigned. Works also for RPCs, actions, and notifications.
* @param[in] priv Arbitrary user-specified pointer.
- * @param[out] prev Optional previous private object of the \p node. Note, that
+ * @param[out] prev_priv_p Optional previous private object of the \p node. Note, that
* the caller is in this case responsible (if it is necessary) for freeing the replaced private object.
* @return LY_ERR value.
*/
-LY_ERR lysc_set_private(const struct lysc_node *node, void *priv, void **prev);
+LY_ERR lysc_set_private(const struct lysc_node *node, void *priv, void **prev_priv_p);
/**
* @brief Get how the if-feature statement currently evaluates.
@@ -2036,17 +2036,6 @@
const struct lysc_node *lysc_node_is_disabled(const struct lysc_node *node, ly_bool recursive);
/**
- * @brief Set a schema private pointer to a user pointer.
- *
- * @param[in] node Node, whose private field will be assigned.
- * @param[in] priv Arbitrary user-specified pointer.
- * @param[out] prev_priv_p Pointer to the previous private data being returned after replacinf by @p priv.
- * @return LY_EINVAL in case of invalid @p node.
- * @return LY_SUCCESS on success.
- */
-LY_ERR lysc_node_set_private(const struct lysc_node *node, void *priv, void **prev_priv_p);
-
-/**
* @brief Check type restrictions applicable to the particular leaf/leaf-list with the given string @p value.
*
* This function check just the type's restriction, if you want to check also the data tree context (e.g. in case of
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index ad28cab..142f2cb 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -1667,46 +1667,3 @@
return 1;
}
-API LY_ERR
-lysc_set_private(const struct lysc_node *node, void *priv, void **prev)
-{
- struct lysc_action *act;
- struct lysc_notif *notif;
-
- LY_CHECK_ARG_RET(NULL, node, LY_EINVAL);
-
- switch (node->nodetype) {
- case LYS_CONTAINER:
- case LYS_CHOICE:
- case LYS_CASE:
- case LYS_LEAF:
- case LYS_LEAFLIST:
- case LYS_LIST:
- case LYS_ANYXML:
- case LYS_ANYDATA:
- if (prev) {
- *prev = node->priv;
- }
- ((struct lysc_node *)node)->priv = priv;
- break;
- case LYS_RPC:
- case LYS_ACTION:
- act = (struct lysc_action *)node;
- if (prev) {
- *prev = act->priv;
- }
- act->priv = priv;
- break;
- case LYS_NOTIF:
- notif = (struct lysc_notif *)node;
- if (prev) {
- *prev = notif->priv;
- }
- notif->priv = priv;
- break;
- default:
- return LY_EINVAL;
- }
-
- return LY_SUCCESS;
-}