fixed datastore cache
This commit is contained in:
parent
e169485985
commit
14faf93eec
7 changed files with 173 additions and 173 deletions
|
|
@ -513,9 +513,9 @@ xml_childvec_get(cxobj *x)
|
|||
* eg for body or attribute
|
||||
*/
|
||||
cxobj *
|
||||
xml_new(char *name,
|
||||
cxobj *xp,
|
||||
void *spec)
|
||||
xml_new(char *name,
|
||||
cxobj *xp,
|
||||
yang_stmt *spec)
|
||||
{
|
||||
cxobj *x;
|
||||
|
||||
|
|
@ -531,7 +531,7 @@ xml_new(char *name,
|
|||
if (xp && xml_child_append(xp, x) < 0)
|
||||
return NULL;
|
||||
x->x_spec = spec; /* Can be NULL */
|
||||
if (xml_child_hash && xml_hash_add(x) < 0)
|
||||
if (xml_child_hash && spec && xml_hash_add(x) < 0)
|
||||
return NULL;
|
||||
return x;
|
||||
}
|
||||
|
|
@ -539,15 +539,15 @@ xml_new(char *name,
|
|||
/*! Return yang spec of node.
|
||||
* Not necessarily set. Either has not been set yet (by xml_spec_set( or anyxml.
|
||||
*/
|
||||
void *
|
||||
yang_stmt *
|
||||
xml_spec(cxobj *x)
|
||||
{
|
||||
return x->x_spec;
|
||||
}
|
||||
|
||||
void *
|
||||
xml_spec_set(cxobj *x,
|
||||
void *spec)
|
||||
int
|
||||
xml_spec_set(cxobj *x,
|
||||
yang_stmt *spec)
|
||||
{
|
||||
x->x_spec = spec;
|
||||
return 0;
|
||||
|
|
@ -1459,6 +1459,7 @@ cxvec_append(cxobj *x,
|
|||
* @note do not delete or move around any children during this function
|
||||
* @note return value > 0 aborts the traversal
|
||||
* @see xml_apply0 including top object
|
||||
* @see xml_apply_ancestor for marking all parents recursively
|
||||
*/
|
||||
int
|
||||
xml_apply(cxobj *xn,
|
||||
|
|
@ -1847,25 +1848,33 @@ xml_hash_key(cxobj *x,
|
|||
|
||||
/*! XML hash add. Create hash and add key/value to parent
|
||||
*
|
||||
* @param[in] arg 0: rm entry, 1: add
|
||||
* @param[in] arg add flag. If 1, else if 0 remove.
|
||||
* Typically called for a whole tree.
|
||||
*/
|
||||
int
|
||||
xml_hash_op(cxobj *x,
|
||||
void *arg)
|
||||
{
|
||||
int add = (intptr_t)arg;
|
||||
#if 1
|
||||
if (add)
|
||||
return xml_hash_add(x);
|
||||
else
|
||||
return xml_hash_rm_entry(x);
|
||||
#else
|
||||
|
||||
int retval = -1;
|
||||
cxobj *xp;
|
||||
clicon_hash_t *ph;
|
||||
yang_stmt *y;
|
||||
cbuf *key = NULL; /* cligen buffer hash key */
|
||||
int op = (intptr_t)arg;
|
||||
|
||||
|
||||
if (xml_hash(x)==NULL){
|
||||
if (op==1)
|
||||
if (add)
|
||||
xml_hash_init(x);
|
||||
}
|
||||
else if (op==0)
|
||||
else if (!add)
|
||||
xml_hash_rm_only(x);
|
||||
if ((xp = xml_parent(x)) == NULL)
|
||||
goto ok;
|
||||
|
|
@ -1881,7 +1890,7 @@ xml_hash_op(cxobj *x,
|
|||
goto done;
|
||||
if (cbuf_len(key)){
|
||||
// fprintf(stderr, "%s add %s = 0x%x\n", __FUNCTION__, cbuf_get(key), (unsigned int)x);
|
||||
if (op == 1){
|
||||
if (add){
|
||||
if (hash_add(ph, cbuf_get(key), &x, sizeof(x)) == NULL)
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -1895,6 +1904,7 @@ xml_hash_op(cxobj *x,
|
|||
if (key)
|
||||
cbuf_free(key);
|
||||
return retval;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*! XML hash add. Create hash and add key/value to parent
|
||||
|
|
@ -1909,6 +1919,7 @@ xml_hash_add(cxobj *x)
|
|||
cxobj *xp;
|
||||
clicon_hash_t *ph;
|
||||
yang_stmt *y;
|
||||
yang_stmt *yp;
|
||||
cbuf *key = NULL; /* cligen buffer hash key */
|
||||
|
||||
if ((ph = xml_hash(x))==NULL){
|
||||
|
|
@ -1917,6 +1928,9 @@ xml_hash_add(cxobj *x)
|
|||
}
|
||||
if ((xp = xml_parent(x)) == NULL)
|
||||
goto ok;
|
||||
yp = xml_spec(xp);
|
||||
if (yp && yp->ys_keyword != Y_LIST)
|
||||
goto ok;
|
||||
if ((y = xml_spec(x)) == NULL)
|
||||
goto ok;
|
||||
if ((key = cbuf_new()) == NULL){
|
||||
|
|
|
|||
|
|
@ -620,9 +620,9 @@ match_base_child(cxobj *x0,
|
|||
int equal;
|
||||
char **b1vec = NULL;
|
||||
int i;
|
||||
cxobj **p;
|
||||
cbuf *key = NULL; /* cligen buffer hash key */
|
||||
size_t vlen;
|
||||
cxobj **p;
|
||||
cbuf *key = NULL; /* cligen buffer hash key */
|
||||
size_t vlen;
|
||||
|
||||
if (xml_child_hash){
|
||||
*x0cp = NULL; /* return value */
|
||||
|
|
@ -1204,7 +1204,7 @@ xml_tree_prune_flagged_sub(cxobj *xt,
|
|||
cxobj *xprev;
|
||||
int iskey;
|
||||
int anykey=0;
|
||||
yang_node *yt;
|
||||
yang_stmt *yt;
|
||||
|
||||
mark = 0;
|
||||
yt = xml_spec(xt); /* xan be null */
|
||||
|
|
@ -1219,7 +1219,7 @@ xml_tree_prune_flagged_sub(cxobj *xt,
|
|||
}
|
||||
/* If it is key dont remove it yet (see second round) */
|
||||
if (yt){
|
||||
if ((iskey = yang_key_match(yt, xml_name(x))) < 0)
|
||||
if ((iskey = yang_key_match((yang_node*)yt, xml_name(x))) < 0)
|
||||
goto done;
|
||||
if (iskey){
|
||||
anykey++;
|
||||
|
|
@ -1247,7 +1247,7 @@ xml_tree_prune_flagged_sub(cxobj *xt,
|
|||
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {
|
||||
/* If it is key remove it here */
|
||||
if (yt){
|
||||
if ((iskey = yang_key_match(yt, xml_name(x))) < 0)
|
||||
if ((iskey = yang_key_match((yang_node*)yt, xml_name(x))) < 0)
|
||||
goto done;
|
||||
if (iskey && xml_purge(x) < 0)
|
||||
goto done;
|
||||
|
|
@ -1858,7 +1858,7 @@ xml_merge1(cxobj *x0,
|
|||
if (y0->yn_keyword == Y_LEAF_LIST || y0->yn_keyword == Y_LEAF){
|
||||
x1bstr = xml_body(x1);
|
||||
if (x0==NULL){
|
||||
if ((x0 = xml_new(x1name, x0p, y0)) == NULL)
|
||||
if ((x0 = xml_new(x1name, x0p, (yang_stmt*)y0)) == NULL)
|
||||
goto done;
|
||||
if (x1bstr){ /* empty type does not have body */
|
||||
if ((x0b = xml_new("body", x0, NULL)) == NULL)
|
||||
|
|
@ -1879,7 +1879,7 @@ xml_merge1(cxobj *x0,
|
|||
} /* if LEAF|LEAF_LIST */
|
||||
else { /* eg Y_CONTAINER, Y_LIST */
|
||||
if (x0==NULL){
|
||||
if ((x0 = xml_new(x1name, x0p, y0)) == NULL)
|
||||
if ((x0 = xml_new(x1name, x0p, (yang_stmt*)y0)) == NULL)
|
||||
goto done;
|
||||
}
|
||||
/* Loop through children of the modification tree */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue