Guard against multiple #inclusions.
Plug a potential memory leak in the jsonObjectToXML
function. If the input parameter was NULL we would fail to free
the growing_buffer we had just allocated. I rearranged it to check
for NULL before allocating the growing_buffer.
Also: I added the static qualifier to the _escape_xml function, to
match the declaration at the top of the file.
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1208
9efc2488-bf62-4759-914b-
345cdb29e865
+#ifndef OSRF_JSON_XML_H
+#define OSRF_JSON_XML_H
+
#ifdef OSRF_JSON_ENABLE_XML_UTILS
#include <stdio.h>
jsonObject* jsonXMLToJSONObject(const char* xml);
#endif
+#endif
char* jsonObjectToXML(const jsonObject* obj) {
- growing_buffer * res_xml;
-
- res_xml = buffer_init(1024);
-
if (!obj)
return strdup("<null/>");
+ growing_buffer * res_xml = buffer_init(1024);
+
_recurse_jsonObjectToXML( obj, res_xml );
return buffer_release(res_xml);
return 1;
}
-char* _escape_xml (const char* text) {
+static char* _escape_xml (const char* text) {
growing_buffer* b = buffer_init(256);
int len = strlen(text);
int i;