From f915dc58a9458a42dceadd2ece94f63e75ef893a Mon Sep 17 00:00:00 2001
From: scottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Date: Fri, 2 Oct 2009 19:02:25 +0000
Subject: [PATCH] Change the return type of jsonObjectGetString so that it is a
 pointer to const char, instead of to non-const char.

We don't want the calling code to be able to modify the innards
of the jsonObject, at least not by this back door.

I have already examined all uses of this function and modified
them where necessary to avoid compile problems.

M    include/opensrf/osrf_json.h
M    src/libopensrf/osrf_json_object.c


git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1803 9efc2488-bf62-4759-914b-345cdb29e865
---
 include/opensrf/osrf_json.h       |  2 +-
 src/libopensrf/osrf_json_object.c | 11 ++++-------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/include/opensrf/osrf_json.h b/include/opensrf/osrf_json.h
index 6307a18..ef82258 100644
--- a/include/opensrf/osrf_json.h
+++ b/include/opensrf/osrf_json.h
@@ -389,7 +389,7 @@ jsonObject* jsonObjectExtractIndex(jsonObject* dest, unsigned long index);
 
 unsigned long jsonObjectRemoveKey( jsonObject* dest, const char* key);
 
-char* jsonObjectGetString(const jsonObject*);
+const char* jsonObjectGetString(const jsonObject*);
 
 double jsonObjectGetNumber( const jsonObject* obj );
 
diff --git a/src/libopensrf/osrf_json_object.c b/src/libopensrf/osrf_json_object.c
index 430cb32..2ef6e3f 100644
--- a/src/libopensrf/osrf_json_object.c
+++ b/src/libopensrf/osrf_json_object.c
@@ -668,8 +668,9 @@ void jsonIteratorFree(jsonIterator* itr) {
 	detectably corrupted, or if the jsonObject to be traversed is of a type other than
 	JSON_HASH or JSON_ARRAY.
 
-	Once jsonIteratorNext has returned NULL, subsequent calls using the same iterator will
-	continue to return NULL.  There is no available function to start over at the beginning.
+	Once jsonIteratorNext has reached the end of the jsonObject that it is traversing,
+	subsequent calls using the same iterator will continue to return NULL.  There is no available
+	function to start over at the beginning.
 
 	The pointer returned, if not NULL, points to an internal element of the jsonObject being
 	traversed.  The calling code should @em not try to free it, but it may modify its contents.
@@ -819,12 +820,8 @@ char* doubleToString( double num ) {
 	If @a obj points to a jsonObject of type JSON_STRING or JSON_NUMBER, the returned value
 	points to the string stored internally (a numeric string in the case of a JSON_NUMBER).
 	Otherwise the returned value is NULL.
-
-	The returned pointer should be treated as a pointer to const.  In particular it should
-	@em not be freed.  In a future release, the returned pointer may indeed be a pointer
-	to const.
 */
-char* jsonObjectGetString(const jsonObject* obj) {
+const char* jsonObjectGetString(const jsonObject* obj) {
 	if(obj)
 	{
 		if( obj->type == JSON_STRING )
-- 
2.11.0