Change the return type of jsonObjectGetString so that it
authorscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 2 Oct 2009 19:02:25 +0000 (19:02 +0000)
committerscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 2 Oct 2009 19:02:25 +0000 (19:02 +0000)
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
src/libopensrf/osrf_json_object.c

index 6307a18..ef82258 100644 (file)
@@ -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 );
 
index 430cb32..2ef6e3f 100644 (file)
@@ -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 )