Yang access function. Mem leak in USE_XML_INSERT
This commit is contained in:
parent
16de5f47ba
commit
e4239496a8
7 changed files with 45 additions and 23 deletions
|
|
@ -203,7 +203,7 @@ example_copy_extra(clicon_handle h, /* Clicon handle */
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
// fprintf(stderr, "%s\n", __FUNCTION__);
|
||||||
retval = 0;
|
retval = 0;
|
||||||
// done:
|
// done:
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
||||||
|
|
@ -138,18 +138,9 @@ typedef enum yang_class yang_class;
|
||||||
|
|
||||||
struct xml;
|
struct xml;
|
||||||
|
|
||||||
/* Yang data node
|
|
||||||
* See RFC7950 Sec 3:
|
|
||||||
* o data node: A node in the schema tree that can be instantiated in a
|
|
||||||
* data tree. One of container, leaf, leaf-list, list, anydata, and
|
|
||||||
* anyxml.
|
|
||||||
* XXX move to function
|
|
||||||
*/
|
|
||||||
#define yang_datanode(y) ((y)->ys_keyword == Y_CONTAINER || (y)->ys_keyword == Y_LEAF || (y)->ys_keyword == Y_LIST || (y)->ys_keyword == Y_LEAF_LIST || (y)->ys_keyword == Y_ANYXML || (y)->ys_keyword == Y_ANYDATA)
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct yang_stmt yang_stmt; /* Defined in clixon_yang_internal */
|
typedef struct yang_stmt yang_stmt; /* Defined in clixon_yang_internal */
|
||||||
|
|
||||||
|
|
||||||
typedef int (yang_applyfn_t)(yang_stmt *ys, void *arg);
|
typedef int (yang_applyfn_t)(yang_stmt *ys, void *arg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -197,6 +188,7 @@ int ys_populate(yang_stmt *ys, void *arg);
|
||||||
yang_stmt *yang_parse_file(int fd, const char *name, yang_stmt *ysp);
|
yang_stmt *yang_parse_file(int fd, const char *name, yang_stmt *ysp);
|
||||||
int yang_apply(yang_stmt *yn, enum rfc_6020 key, yang_applyfn_t fn,
|
int yang_apply(yang_stmt *yn, enum rfc_6020 key, yang_applyfn_t fn,
|
||||||
void *arg);
|
void *arg);
|
||||||
|
int yang_datanode(yang_stmt *ys);
|
||||||
int yang_abs_schema_nodeid(yang_stmt *yspec, yang_stmt *ys,
|
int yang_abs_schema_nodeid(yang_stmt *yspec, yang_stmt *ys,
|
||||||
char *schema_nodeid,
|
char *schema_nodeid,
|
||||||
enum rfc_6020 keyword, yang_stmt **yres);
|
enum rfc_6020 keyword, yang_stmt **yres);
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,9 @@ text_modify(clicon_handle h,
|
||||||
}
|
}
|
||||||
#ifdef USE_XML_INSERT
|
#ifdef USE_XML_INSERT
|
||||||
/* Add new xml node but without parent - insert when node fully
|
/* Add new xml node but without parent - insert when node fully
|
||||||
copied (see changed conditional below) */
|
* copied (see changed conditional below)
|
||||||
|
* Note x0 may dangle cases if exit before changed conditional
|
||||||
|
*/
|
||||||
if ((x0 = xml_new(x1name, NULL, (yang_stmt*)y0)) == NULL)
|
if ((x0 = xml_new(x1name, NULL, (yang_stmt*)y0)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
#else
|
#else
|
||||||
|
|
@ -400,6 +402,11 @@ text_modify(clicon_handle h,
|
||||||
#endif
|
#endif
|
||||||
retval = 1;
|
retval = 1;
|
||||||
done:
|
done:
|
||||||
|
#ifdef USE_XML_INSERT
|
||||||
|
/* Remove dangling added objects */
|
||||||
|
if (changed && x0 && xml_parent(x0)==NULL)
|
||||||
|
xml_purge(x0);
|
||||||
|
#endif
|
||||||
if (x0vec)
|
if (x0vec)
|
||||||
free(x0vec);
|
free(x0vec);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
||||||
|
|
@ -934,9 +934,9 @@ xml_wrap(cxobj *xc,
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1
|
* @retval -1
|
||||||
* @note you cannot remove xchild in the loop (unless yoy keep track of xprev)
|
* @note you cannot remove xchild in the loop (unless yoy keep track of xprev)
|
||||||
*
|
* @note Linear complexity - use xml_child_rm if possible
|
||||||
* @see xml_free Free, dont remove from parent
|
* @see xml_free Free, dont remove from parent
|
||||||
* @see xml_child_rm Only remove dont free
|
* @see xml_child_rm Remove if child order is known (does not free)
|
||||||
* Differs from xml_free it is removed from parent.
|
* Differs from xml_free it is removed from parent.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
|
|
|
||||||
|
|
@ -2867,6 +2867,26 @@ yang_apply(yang_stmt *yn,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Check if a node is a yang "data node"
|
||||||
|
* @param[in] ys Yang statement node
|
||||||
|
* @retval 0 Yang node is NOT a data node
|
||||||
|
* @retval !=0 Yang node IS a data noed
|
||||||
|
* @see RFC7950 Sec 3:
|
||||||
|
* o data node: A node in the schema tree that can be instantiated in a
|
||||||
|
* data tree. One of container, leaf, leaf-list, list, anydata, and
|
||||||
|
* anyxml.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
yang_datanode(yang_stmt *ys)
|
||||||
|
{
|
||||||
|
return (yang_keyword_get(ys) == Y_CONTAINER ||
|
||||||
|
yang_keyword_get(ys) == Y_LEAF ||
|
||||||
|
yang_keyword_get(ys) == Y_LIST ||
|
||||||
|
yang_keyword_get(ys) == Y_LEAF_LIST ||
|
||||||
|
yang_keyword_get(ys) == Y_ANYXML ||
|
||||||
|
yang_keyword_get(ys) == Y_ANYDATA);
|
||||||
|
}
|
||||||
|
|
||||||
/*! All the work for schema_nodeid functions both absolute and descendant
|
/*! All the work for schema_nodeid functions both absolute and descendant
|
||||||
* Ignore prefixes, see _abs
|
* Ignore prefixes, see _abs
|
||||||
* @param[in] yn Yang node. Find next yang stmt and return that if match.
|
* @param[in] yn Yang node. Find next yang stmt and return that if match.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
|
|
||||||
# Number of list/leaf-list entries in file
|
# Number of list/leaf-list entries in file
|
||||||
: ${perfnr:=20000}
|
: ${perfnr:=10000}
|
||||||
|
|
||||||
# Number of requests made get/put
|
# Number of requests made get/put
|
||||||
: ${perfreq:=100}
|
: ${perfreq:=100}
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,8 @@ testrun startup "$runvar" "$startvar" "$extravar" '<data><interfaces xmlns="urn:
|
||||||
# 2. Try different modes on Invalid running/startup/extra WITHOUT failsafe
|
# 2. Try different modes on Invalid running/startup/extra WITHOUT failsafe
|
||||||
# ensure all db:s are unchanged after failure.
|
# ensure all db:s are unchanged after failure.
|
||||||
|
|
||||||
|
# Valgrind backend tests make no sense in backend crash tests
|
||||||
|
if [ $valgrindtest -ne 2 ]; then
|
||||||
new "Test invalid running in running mode"
|
new "Test invalid running in running mode"
|
||||||
testfail running "$invalidvar" "$startvar" "$extravar"
|
testfail running "$invalidvar" "$startvar" "$extravar"
|
||||||
|
|
||||||
|
|
@ -180,5 +182,6 @@ testfail running "$brokenvar" "$startvar" "$extravar"
|
||||||
|
|
||||||
new "Run broken startup in startup mode"
|
new "Run broken startup in startup mode"
|
||||||
testfail startup "$runvar" "$brokenvar" "$extravar"
|
testfail startup "$runvar" "$brokenvar" "$extravar"
|
||||||
|
fi
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue