X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fxml_match.c;h=7dddb6f07c5be722841e88b080b4aff97be11466;hp=ab0e4b18cfdbd91482a827af8da22a9834bf1fe2;hb=a5043f3ecfd59cd1f788f982f475abdc11327997;hpb=23d3217defe73218069ac17be28742b39637a144 diff --git a/src/xml_match.c b/src/xml_match.c index ab0e4b1..7dddb6f 100644 --- a/src/xml_match.c +++ b/src/xml_match.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ /** @@ -10,18 +10,14 @@ #include #endif -#include - #include -#include #if YAZ_HAVE_XML2 -#include -#include #include "sru-p.h" int yaz_match_xsd_element(xmlNodePtr ptr, const char *elem) { - if (ptr->type == XML_ELEMENT_NODE && !xmlStrcmp(ptr->name, BAD_CAST elem)) + if (ptr && ptr->type == XML_ELEMENT_NODE && + !xmlStrcmp(ptr->name, BAD_CAST elem)) { return 1; } @@ -30,8 +26,8 @@ int yaz_match_xsd_element(xmlNodePtr ptr, const char *elem) #define CHECK_TYPE 0 -int yaz_match_xsd_string_n(xmlNodePtr ptr, const char *elem, ODR o, - char **val, int *len) +int yaz_match_xsd_string_n_nmem(xmlNodePtr ptr, const char *elem, NMEM nmem, + char **val, int *len) { #if CHECK_TYPE struct _xmlAttr *attr; @@ -60,12 +56,17 @@ int yaz_match_xsd_string_n(xmlNodePtr ptr, const char *elem, ODR o, *val = ""; return 1; } - *val = odr_strdup(o, (const char *) ptr->content); + *val = nmem_strdup(nmem, (const char *) ptr->content); if (len) *len = xmlStrlen(ptr->content); return 1; } +int yaz_match_xsd_string_n(xmlNodePtr ptr, const char *elem, ODR o, + char **val, int *len) +{ + return yaz_match_xsd_string_n_nmem(ptr, elem, o->mem, val, len); +} int yaz_match_xsd_string(xmlNodePtr ptr, const char *elem, ODR o, char **val) { @@ -107,10 +108,7 @@ int yaz_match_xsd_XML_n2(xmlNodePtr ptr, const char *elem, ODR o, xmlBufferAddHead(buf, (const xmlChar *) "", -1); xmlBufferAdd(buf, (const xmlChar *) "", -1); } - *val = (char *) odr_malloc(o, buf->use + 1); - memcpy(*val, buf->content, buf->use); - (*val)[buf->use] = '\0'; - + *val = odr_strdupn(o, (const char *) buf->content, buf->use); if (len) *len = buf->use;