From ebae6a6fda327427cdd163716b658af36cbdaa46 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 31 Jan 2008 19:46:21 +0000 Subject: [PATCH] Patch from Scott McKellar (including commentary): 1. I added the const qualifier to the second parameter of xmlSaxAttr(). 2. I moved the prototype of _xmlToJSON() from the header to the implementation file, and made the function static. At least in its present form, _xmlToJSON should not be part of the public interface because it is confusing. Sometimes it allocates a new jsonObject, which needs to be freed, and sometimes it doesn't. A better design would be for it to expect to receive a non-NULL pointer to an existing jsonObject. Since it is called in only one place (other than a couple of recursive calls), this would be an easy change to make. However I left it alone -- as long as the function is visible only from within its own source file, the potential for confusion is limited. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1244 9efc2488-bf62-4759-914b-345cdb29e865 --- include/opensrf/xml_utils.h | 5 +---- src/libopensrf/xml_utils.c | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/opensrf/xml_utils.h b/include/opensrf/xml_utils.h index e0321a4..42318f9 100644 --- a/include/opensrf/xml_utils.h +++ b/include/opensrf/xml_utils.h @@ -7,9 +7,6 @@ jsonObject* xmlDocToJSON(xmlDocPtr doc); -/* helper function */ -jsonObject* _xmlToJSON(xmlNodePtr node, jsonObject*); - /* debug function, prints each node and content */ void recurse_doc( xmlNodePtr node ); @@ -25,7 +22,7 @@ char* xmlDocToString(xmlDocPtr doc, int full); /* Takes an xmlChar** from a SAX callback and returns the value for the attribute with name 'name' */ -char* xmlSaxAttr( const xmlChar** atts, char* name ); +char* xmlSaxAttr( const xmlChar** atts, const char* name ); /** Sets the xml attributes from atts to the given dom node diff --git a/src/libopensrf/xml_utils.c b/src/libopensrf/xml_utils.c index ec9e5c3..2bdb4ce 100644 --- a/src/libopensrf/xml_utils.c +++ b/src/libopensrf/xml_utils.c @@ -1,5 +1,7 @@ #include +/* helper function */ +static jsonObject* _xmlToJSON(xmlNodePtr node, jsonObject*); void recurse_doc( xmlNodePtr node ) { if( node == NULL ) return; @@ -18,7 +20,7 @@ jsonObject* xmlDocToJSON(xmlDocPtr doc) { return _xmlToJSON(xmlDocGetRootElement(doc), NULL); } -jsonObject* _xmlToJSON(xmlNodePtr node, jsonObject* obj) { +static jsonObject* _xmlToJSON(xmlNodePtr node, jsonObject* obj) { if(!node) return NULL; if(xmlIsBlankNode(node)) return NULL; @@ -93,7 +95,7 @@ char* xmlDocToString(xmlDocPtr doc, int full) { -char* xmlSaxAttr( const xmlChar** atts, char* name ) { +char* xmlSaxAttr( const xmlChar** atts, const char* name ) { if( atts && name ) { int i; for(i = 0; (atts[i] != NULL); i++) { -- 2.11.0