Restore xmldb_get() to original (but removed one parameter

Moved all zero-copy xmldb_get functions to xmldb_get0.
Clarified CHANGELOG for xmldb_get changes
This commit is contained in:
Olof hagsand 2019-06-04 11:14:03 +02:00
parent 2aeb925521
commit 3dba0b5370
11 changed files with 93 additions and 66 deletions

View file

@ -183,7 +183,7 @@ startup_common(clicon_handle h,
if ((msd = modstate_diff_new()) == NULL)
goto done;
clicon_debug(1, "Reading startup config from %s", db);
if (xmldb_get(h, db, "/", 0, &xt, msd) < 0)
if (xmldb_get0(h, db, "/", 0, &xt, msd) < 0)
goto done;
/* Clear flags xpath for get */
xml_apply0(xt, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset,
@ -283,7 +283,7 @@ startup_validate(clicon_handle h,
}
plugin_transaction_end(h, td);
/* Clear cached trees from default values and marking */
if (xmldb_get_clear(h, td->td_target) < 0)
if (xmldb_get0_clear(h, td->td_target) < 0)
goto done;
if (xtr){
*xtr = td->td_target;
@ -292,7 +292,7 @@ startup_validate(clicon_handle h,
retval = 1;
done:
if (td){
xmldb_get_free(h, &td->td_target);
xmldb_get0_free(h, &td->td_target);
transaction_free(td);
}
return retval;
@ -335,7 +335,7 @@ startup_commit(clicon_handle h,
if (plugin_transaction_commit(h, td) < 0)
goto done;
/* Clear cached trees from default values and marking */
if (xmldb_get_clear(h, td->td_target) < 0)
if (xmldb_get0_clear(h, td->td_target) < 0)
goto done;
/* [Delete and] create running db */
@ -360,7 +360,7 @@ startup_commit(clicon_handle h,
if (td){
if (retval < 1)
plugin_transaction_abort(h, td);
xmldb_get_free(h, &td->td_target);
xmldb_get0_free(h, &td->td_target);
transaction_free(td);
}
return retval;
@ -398,7 +398,7 @@ from_validate_common(clicon_handle h,
goto done;
}
/* This is the state we are going to */
if (xmldb_get(h, candidate, "/", 0, &td->td_target, NULL) < 0)
if (xmldb_get0(h, candidate, "/", 0, &td->td_target, NULL) < 0)
goto done;
/* Clear flags xpath for get */
@ -416,7 +416,7 @@ from_validate_common(clicon_handle h,
/* 2. Parse xml trees
* This is the state we are going from */
if (xmldb_get(h, "running", "/", 0, &td->td_src, NULL) < 0)
if (xmldb_get0(h, "running", "/", 0, &td->td_src, NULL) < 0)
goto done;
/* Clear flags xpath for get */
xml_apply0(td->td_src, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset,
@ -521,9 +521,9 @@ candidate_commit(clicon_handle h,
goto done;
/* Clear cached trees from default values and marking */
if (xmldb_get_clear(h, td->td_target) < 0)
if (xmldb_get0_clear(h, td->td_target) < 0)
goto done;
if (xmldb_get_clear(h, td->td_src) < 0)
if (xmldb_get0_clear(h, td->td_src) < 0)
goto done;
/* Optionally write (potentially modified) tree back to candidate
@ -559,8 +559,8 @@ candidate_commit(clicon_handle h,
if (td){
if (retval < 1)
plugin_transaction_abort(h, td);
xmldb_get_free(h, &td->td_target);
xmldb_get_free(h, &td->td_src);
xmldb_get0_free(h, &td->td_target);
xmldb_get0_free(h, &td->td_src);
transaction_free(td);
}
return retval;
@ -744,10 +744,10 @@ from_client_validate(clicon_handle h,
goto ok;
}
/* Clear cached trees from default values and marking */
if (xmldb_get_clear(h, td->td_target) < 0)
if (xmldb_get0_clear(h, td->td_target) < 0)
goto done;
if (xmldb_get_clear(h, td->td_src) < 0 ||
xmldb_get_clear(h, td->td_target) < 0){
if (xmldb_get0_clear(h, td->td_src) < 0 ||
xmldb_get0_clear(h, td->td_target) < 0){
plugin_transaction_abort(h, td);
goto done;
}
@ -769,8 +769,8 @@ from_client_validate(clicon_handle h,
if (td){
if (retval < 0)
plugin_transaction_abort(h, td);
xmldb_get_free(h, &td->td_target);
xmldb_get_free(h, &td->td_src);
xmldb_get0_free(h, &td->td_target);
xmldb_get0_free(h, &td->td_src);
transaction_free(td);
}
return retval;