os_xml review

changes:
* remove global XML_VAR compile directive
* restructure header structure (os_xml.h + os_xml_writer.h -> os_xml.h (for external includes) + os_xml_internal.h (for internal macros)
* always ensure valid OS_XML state so OS_ClearXML() never encounter a nullpointer or memory leak
* remove unused function _checkmemory()
* clean up memory in failure branches
* fix a bunch of compiler warnings
* add test cases