Skip to content

Commit b3a6e48

Browse files
committed
libyang CHANGE allow ctx to be NULL and read from another parameter
Fixes CESNET/netopeer2#177
1 parent d838835 commit b3a6e48

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/context.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,11 +1534,15 @@ ly_ctx_get_node(struct ly_ctx *ctx, const struct lys_node *start, const char *no
15341534
{
15351535
const struct lys_node *node;
15361536

1537-
if (!ctx || !nodeid || ((nodeid[0] != '/') && !start)) {
1537+
if ((!ctx && !start) || !nodeid || ((nodeid[0] != '/') && !start)) {
15381538
ly_errno = LY_EINVAL;
15391539
return NULL;
15401540
}
15411541

1542+
if (!ctx) {
1543+
ctx = start->module->ctx;
1544+
}
1545+
15421546
/* sets error and everything */
15431547
node = resolve_json_nodeid(nodeid, ctx, start, output);
15441548

src/libyang.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,9 +1347,9 @@ const struct lys_submodule *ly_ctx_get_submodule2(const struct lys_module *main_
13471347
* This function is primarily meant as a utility function to ease getting specific schema nodes
13481348
* directly from context having data_path a const immutable string.
13491349
*
1350-
* @param[in] ctx Context to work in.
1350+
* @param[in] ctx Context to work in. Must be set if \p start is NULL.
13511351
* @param[in] start Starting node for a relative schema node identifier, in which
1352-
* case it is mandatory.
1352+
* case it is mandatory and \p ctx can be NULL.
13531353
* @param[in] data_path JSON schema node identifier.
13541354
* @param[in] output Search operation output instead input.
13551355
* @return Resolved schema node or NULL.

0 commit comments

Comments
 (0)