Introduce virXMLValidatorFree

Split out the code cleaning up the validator.
This commit is contained in:
Ján Tomko 2016-06-07 18:57:29 +02:00
parent 71c68b40df
commit 8657c7a12f
3 changed files with 14 additions and 1 deletions

View File

@ -2565,6 +2565,7 @@ virXMLPickShellSafeComment;
virXMLPropString;
virXMLSaveFile;
virXMLValidateAgainstSchema;
virXMLValidatorFree;
virXPathBoolean;
virXPathInt;
virXPathLong;

View File

@ -1161,11 +1161,21 @@ virXMLValidateAgainstSchema(const char *schemafile,
ret = 0;
cleanup:
virXMLValidatorFree(validator);
return ret;
}
void
virXMLValidatorFree(virXMLValidatorPtr validator)
{
if (!validator)
return;
VIR_FREE(validator->schemafile);
virBufferFreeAndReset(&validator->buf);
xmlRelaxNGFreeParserCtxt(validator->rngParser);
xmlRelaxNGFreeValidCtxt(validator->rngValid);
xmlRelaxNGFree(validator->rng);
VIR_FREE(validator);
return ret;
}

View File

@ -192,5 +192,7 @@ typedef virXMLValidator *virXMLValidatorPtr;
int
virXMLValidateAgainstSchema(const char *schemafile,
xmlDocPtr xml);
void
virXMLValidatorFree(virXMLValidatorPtr validator);
#endif /* __VIR_XML_H__ */