Hi,
On Tuesday 26 August 2014 09:34:42 Shahar Havivi wrote:
I am trying to add xmlXPathRegisterNs() to v2v/xml-c.c but I get a
seg
fault, the signature should be:
http://xmlsoft.org/html/libxml-xpathInternals.html#xmlXPathRegisterNs
I think I am wrong in CAMLparam and CAMLlocal...,
Following is the patch:
======================================================================
diff --git a/v2v/xml-c.c b/v2v/xml-c.c
index 4c9bc77..a917c24 100644
--- a/v2v/xml-c.c
+++ b/v2v/xml-c.c
@@ -141,6 +141,16 @@ v2v_xml_xpath_new_context (value docv)
}
value
+v2v_xml_xpath_register_ns (value prefix, value uri, value xpathctx)
+{
+ CAMLparam3 (prefix, uri, xpathctx);
+ CAMLlocal1 (retval);
+ retval = xmlXPathRegisterNs (BAD_CAST String_val (prefix), BAD_CAST String_val (uri),
xpathctx);
+
+ CAMLreturn (retval);
+}
+
First of all, you are using the xpathctx parameter directly as
parameter for xmlXPathRegisterNs, while it is an OCaml value which
wraps the actual object; see how it is done in e.g.
v2v_xml_xpath_eval_expression, using the Xpathctx_val macro.
Second, the order of the arguments in your xmlXPathRegisterNs is wrong:
- yours: xmlXPathRegisterNs(prefix, uri, ctxt)
- actual function: xmlXPathRegisterNs(ctxt, prefix, uri)
--
Pino Toscano