summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-09-16 12:13:42 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-09-16 12:16:55 +0200
commit8855ce5a79dc43c7751c419c0f8af37f445ab9d8 (patch)
tree709669a8f54d790ebd9c2a48ec816c2900c95b9c
parentc1bbaf4050c25f323ab6c37492608de8ecb66968 (diff)
downloadrockbox-8855ce5.tar.gz
rockbox-8855ce5.tar.bz2
rockbox-8855ce5.zip
regtools/soc_desc: fix libxml2 misinit
The code did not call xmlInitParser() and would call xmlCleanupParser() each time which is doubly wrong because 1) it's not init 2) all init/cleanup must be done from the main thread. To ensure 2), call it from a static ctor. Change-Id: I3d191bf3b8c0cfc51da78157e88c786636fd3ebf Reviewed-on: http://gerrit.rockbox.org/966 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
-rw-r--r--utils/regtools/lib/soc_desc.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/utils/regtools/lib/soc_desc.cpp b/utils/regtools/lib/soc_desc.cpp
index 1c9eaf7972..3904f6a77e 100644
--- a/utils/regtools/lib/soc_desc.cpp
+++ b/utils/regtools/lib/soc_desc.cpp
@@ -293,7 +293,6 @@ bool soc_desc_parse_xml(const std::string& filename, soc_t& socs)
bool ret = parse_root_elem(root_element, socs);
xmlFreeDoc(doc);
- xmlCleanupParser();
return ret;
}
@@ -967,3 +966,20 @@ bool soc_desc_evaluate_formula(const std::string& formula,
my_evaluator e(formula, var);
return e.parse(result, error);
}
+
+/** WARNING we need to call xmlInitParser() to init libxml2 but it needs to
+ * called from the main thread, which is a super strong requirement, so do it
+ * using a static constructor */
+namespace
+{
+class xml_parser_init
+{
+public:
+ xml_parser_init()
+ {
+ xmlInitParser();
+ }
+};
+
+xml_parser_init __xml_parser_init;
+}