These patches make two changes:

1. They eliminate a const-removing cast from jsonObjectToJSON().  This
cast is no longer necessary now that a recent patch has changed the 
signature of jsonObjectEncodeClass().

2. They move the JSON_INIT_CLEAR macro out of the header file and into 
the implementation file.  No other file invokes this macro -- nor
could it, since the macro refers to two static functions within
osrf_json_object.c.  Strictly speaking another file could provide
other functions with the same signatures, but I doubt that any such
usage was ever intended.

Scott McKellar
http://home.swbell.net/mck9/ct/

Developer's Certificate of Origin 1.1 By making a contribution to
this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license indicated
in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source license
and I have the right under that license to submit that work with
modifications, whether created in whole or in part by me, under the
same open source license (unless I am permitted to submit under a
different license), as indicated in the file; or

(c) The contribution was provided directly to me by some other person
who certified (a), (b) or (c) and I have not modified it; and

(d) In the case of each of (a), (b), or (c), I understand and agree
that this project and the contribution are public and that a record
of the contribution (including all personal information I submit
with it, including my sign-off) is maintained indefinitely and may
be redistributed consistent with this project or the open source
license indicated in the file.
*** trunk/src/libopensrf/osrf_json_object.c	2007-09-02 08:35:16.000000000 -0500
--- trunk-mod/src/libopensrf/osrf_json_object.c	2007-09-02 14:26:33.000000000 -0500
***************
*** 16,21 ****
--- 16,44 ----
  #include <opensrf/osrf_json.h>
  #include <opensrf/osrf_json_utils.h>
  
+ /* cleans up an object if it is morphing another object, also
+  * verifies that the appropriate storage container exists where appropriate */
+ #define JSON_INIT_CLEAR(_obj_, newtype)		\
+ 	if( _obj_->type == JSON_HASH && newtype != JSON_HASH ) {			\
+ 		osrfHashFree(_obj_->value.h);			\
+ 		_obj_->value.h = NULL; 					\
+ } else if( _obj_->type == JSON_ARRAY && newtype != JSON_ARRAY ) {	\
+ 		osrfListFree(_obj_->value.l);			\
+ 		_obj_->value.l = NULL;					\
+ } else if( _obj_->type == JSON_STRING && newtype != JSON_STRING ) { \
+ 		free(_obj_->value.s);						\
+ 		_obj_->value.s = NULL;					\
+ } \
+ 	_obj_->type = newtype;\
+ 	if( newtype == JSON_HASH && _obj_->value.h == NULL ) {	\
+ 		_obj_->value.h = osrfNewHash();		\
+ 		_obj_->value.h->freeItem = _jsonFreeHashItem; \
+ } else if( newtype == JSON_ARRAY && _obj_->value.l == NULL ) {	\
+ 		_obj_->value.l = osrfNewList();		\
+ 		_obj_->value.l->freeItem = _jsonFreeListItem;\
+ }
+ 
+ 
  jsonObject* jsonNewObject(const char* data) {
  
  	jsonObject* o;
***************
*** 133,139 ****
  }
  
  char* jsonObjectToJSON( const jsonObject* obj ) {
! 	jsonObject* obj2 = jsonObjectEncodeClass( (jsonObject*) obj);
  	char* json = jsonObjectToJSONRaw(obj2);
  	jsonObjectFree(obj2);
  	return json;
--- 156,162 ----
  }
  
  char* jsonObjectToJSON( const jsonObject* obj ) {
! 	jsonObject* obj2 = jsonObjectEncodeClass( obj );
  	char* json = jsonObjectToJSONRaw(obj2);
  	jsonObjectFree(obj2);
  	return json;
*** trunk/include/opensrf/osrf_json_utils.h	2007-09-02 08:35:14.000000000 -0500
--- trunk-mod/include/opensrf/osrf_json_utils.h	2007-09-02 14:25:49.000000000 -0500
***************
*** 34,64 ****
  
  #define JSON_NUMBER_CHARS "0123456789.+-e"
  
! 
! /* cleans up an object if it is morphing another object, also
!  * verifies that the appropriate storage container exists where appropriate */
! #define JSON_INIT_CLEAR(_obj_, newtype)		\
! 	if( _obj_->type == JSON_HASH && newtype != JSON_HASH ) {			\
! 		osrfHashFree(_obj_->value.h);			\
! 		_obj_->value.h = NULL; 					\
! 	} else if( _obj_->type == JSON_ARRAY && newtype != JSON_ARRAY ) {	\
! 		osrfListFree(_obj_->value.l);			\
! 		_obj_->value.l = NULL;					\
! 	} else if( _obj_->type == JSON_STRING && newtype != JSON_STRING ) { \
! 		free(_obj_->value.s);						\
! 		_obj_->value.s = NULL;					\
! 	} \
! 	_obj_->type = newtype;\
! 	if( newtype == JSON_HASH && _obj_->value.h == NULL ) {	\
! 		_obj_->value.h = osrfNewHash();		\
! 		_obj_->value.h->freeItem = _jsonFreeHashItem; \
! 	} else if( newtype == JSON_ARRAY && _obj_->value.l == NULL ) {	\
! 		_obj_->value.l = osrfNewList();		\
! 		_obj_->value.l->freeItem = _jsonFreeListItem;\
! 	}												\
! 
! 
! /** 
   * These are the callbacks through which the top level parser 
   * builds objects via the push parser
   */
--- 34,40 ----
  
  #define JSON_NUMBER_CHARS "0123456789.+-e"
  
! /**
   * These are the callbacks through which the top level parser 
   * builds objects via the push parser
   */

Reply via email to