Re-add yang ref-count for obsolete yangs in readfile
This commit is contained in:
parent
fa93364953
commit
fd4e694312
5 changed files with 60 additions and 8 deletions
|
|
@ -425,6 +425,47 @@ yang_cvec_rm(yang_stmt *ys,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*! Get yang object reference count
|
||||
*
|
||||
* @param[in] ys Yang statement
|
||||
* @retval ref Reference coun t
|
||||
*/
|
||||
int
|
||||
yang_ref_get(yang_stmt *ys)
|
||||
{
|
||||
return ys->ys_ref;
|
||||
}
|
||||
|
||||
/*! Increment yang object reference count with +1
|
||||
*
|
||||
* @param[in] ys Yang statement
|
||||
* @retval 0
|
||||
*/
|
||||
int
|
||||
yang_ref_inc(yang_stmt *ys)
|
||||
{
|
||||
ys->ys_ref++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! Decrement yang object reference count with -1
|
||||
*
|
||||
* @param[in] ys Yang statement
|
||||
* @retval 0 Ok
|
||||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
yang_ref_dec(yang_stmt *ys)
|
||||
{
|
||||
int retval = -1;
|
||||
|
||||
if (ys->ys_ref > 0)
|
||||
ys->ys_ref--;
|
||||
retval = 0;
|
||||
// done:
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*! Get yang stmt flags, used for internal algorithms
|
||||
*
|
||||
* @param[in] ys Yang statement
|
||||
|
|
@ -1154,8 +1195,13 @@ ys_freechildren(yang_stmt *ys)
|
|||
int
|
||||
ys_free(yang_stmt *ys)
|
||||
{
|
||||
ys_freechildren(ys);
|
||||
ys_free1(ys, 1);
|
||||
if (yang_ref_get(ys) > 0){
|
||||
yang_ref_dec(ys);
|
||||
}
|
||||
else {
|
||||
ys_freechildren(ys);
|
||||
ys_free1(ys, 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue