[Opensrf-commits] r1244 - in trunk: include/opensrf src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jan 31 15:14:00 EST 2008


Author: miker
Date: 2008-01-31 14:46:21 -0500 (Thu, 31 Jan 2008)
New Revision: 1244

Modified:
   trunk/include/opensrf/xml_utils.h
   trunk/src/libopensrf/xml_utils.c
Log:
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.



Modified: trunk/include/opensrf/xml_utils.h
===================================================================
--- trunk/include/opensrf/xml_utils.h	2008-01-31 19:39:02 UTC (rev 1243)
+++ trunk/include/opensrf/xml_utils.h	2008-01-31 19:46:21 UTC (rev 1244)
@@ -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 @@
 /* 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 

Modified: trunk/src/libopensrf/xml_utils.c
===================================================================
--- trunk/src/libopensrf/xml_utils.c	2008-01-31 19:39:02 UTC (rev 1243)
+++ trunk/src/libopensrf/xml_utils.c	2008-01-31 19:46:21 UTC (rev 1244)
@@ -1,5 +1,7 @@
 #include <opensrf/xml_utils.h>
 
+/* helper function */
+static jsonObject* _xmlToJSON(xmlNodePtr node, jsonObject*);
 
 void recurse_doc( xmlNodePtr node ) {
 	if( node == NULL ) return;
@@ -18,7 +20,7 @@
 	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* 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++) {



More information about the opensrf-commits mailing list