Simplify in a lot of places using odr_strdupn
[yaz-moved-to-github.git] / src / xml_match.c
index dd804db..b36e2f7 100644 (file)
@@ -107,10 +107,7 @@ int yaz_match_xsd_XML_n2(xmlNodePtr ptr, const char *elem, ODR o,
         xmlBufferAddHead(buf, (const xmlChar *) "<yaz_record>", -1);
         xmlBufferAdd(buf, (const xmlChar *) "</yaz_record>", -1);
     }
-    *val = (char *) odr_malloc(o, buf->use + 1);
-    memcpy(*val, buf->content, buf->use);
-    (*val)[buf->use] = '\0';
-
+    *val = odr_strdupn(o, buf->content, buf->use);
     if (len)
         *len = buf->use;