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
jsonObject* xmlDocToJSON(xmlDocPtr doc);
-/* helper function */
-jsonObject* _xmlToJSON(xmlNodePtr node, jsonObject*);
-
/* debug function, prints each node and content */
void recurse_doc( xmlNodePtr node );
/* 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
#include <opensrf/xml_utils.h>
+/* helper function */
+static jsonObject* _xmlToJSON(xmlNodePtr node, jsonObject*);
void recurse_doc( xmlNodePtr node ) {
if( node == NULL ) return;
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;
-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++) {