27#include <libxml/parser.h> 28#include <libxml/tree.h> 51static XmlDocSlot g_xml_docs[64];
52static XmlNodeSlot g_xml_nodes[256];
62static int xml_doc_alloc(xmlDocPtr d) {
63 for (
int i = 1; i < (int)(
sizeof(g_xml_docs) /
sizeof(g_xml_docs[0])); ++i) {
64 if (!g_xml_docs[i].in_use) {
65 g_xml_docs[i].in_use = 1;
66 g_xml_docs[i].doc = d;
78static xmlDocPtr xml_doc_get(
int h) {
79 if (h > 0 && h < (
int)(
sizeof(g_xml_docs) /
sizeof(g_xml_docs[0])) && g_xml_docs[h].in_use)
return g_xml_docs[h].doc;
88static int xml_doc_free_handle(
int h) {
89 if (h <= 0 || h >= (
int)(
sizeof(g_xml_docs) /
sizeof(g_xml_docs[0])) || !g_xml_docs[h].in_use)
return 0;
90 if (g_xml_docs[h].doc) xmlFreeDoc(g_xml_docs[h].doc);
91 g_xml_docs[h].doc = NULL;
92 g_xml_docs[h].in_use = 0;
104static int xml_node_alloc(xmlNodePtr
n) {
105 for (
int i = 1; i < (int)(
sizeof(g_xml_nodes) /
sizeof(g_xml_nodes[0])); ++i) {
106 if (!g_xml_nodes[i].in_use) {
107 g_xml_nodes[i].in_use = 1;
108 g_xml_nodes[i].node =
n;
120static xmlNodePtr xml_node_get(
int h) {
121 if (h > 0 && h < (
int)(
sizeof(g_xml_nodes) /
sizeof(g_xml_nodes[0])) && g_xml_nodes[h].in_use)
return g_xml_nodes[h].node;
133static int xml_node_free_handle(
int h) {
134 if (h <= 0 || h >= (
int)(
sizeof(g_xml_nodes) /
sizeof(g_xml_nodes[0])) || !g_xml_nodes[h].in_use)
return 0;
136 g_xml_nodes[h].node = NULL;
137 g_xml_nodes[h].in_use = 0;