[Opensrf-commits] r1237 - trunk/src/srfsh

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jan 31 14:40:24 EST 2008


Author: miker
Date: 2008-01-31 14:12:40 -0500 (Thu, 31 Jan 2008)
New Revision: 1237

Modified:
   trunk/src/srfsh/srfsh.c
Log:
Patch from Scott McKellar:

1. In send_request() we allocate a jsonObject o and then immediately
assign the resulting pointer to params.  I eliminated the rather
pointless o and allocated params directly.

2. We didn't ever free params.  Now we do.

3. I replaced two deprecated identifiers with their camel-case
equivalents:

   osrf_app_client_session_init   ==> osrfAppSessionClientInit
   osrf_message_free              ==> osrfMessageFree



Modified: trunk/src/srfsh/srfsh.c
===================================================================
--- trunk/src/srfsh/srfsh.c	2008-01-31 19:09:46 UTC (rev 1236)
+++ trunk/src/srfsh/srfsh.c	2008-01-31 19:12:40 UTC (rev 1237)
@@ -557,30 +557,31 @@
 			return 1;
 		}
 		else {
-			jsonObject* o = jsonNewObject(NULL);
-			jsonObjectPush(o, last_result->_result_content );
-			params = o;
+			params = jsonNewObject(NULL);
+			jsonObjectPush(params, last_result->_result_content );
 		}
 	}
 
 
 	if(buffer->n_used > 0 && params == NULL) {
 		fprintf(stderr, "JSON error detected, not executing\n");
+		jsonObjectFree(params);
 		return 1;
 	}
 
-	osrfAppSession* session = osrf_app_client_session_init(server);
+	osrfAppSession* session = osrfAppSessionClientInit(server);
 
 	if(!osrf_app_session_connect(session)) {
 		osrfLogWarning( OSRF_LOG_MARK,  "Unable to connect to remote service %s\n", server );
+		jsonObjectFree(params);
 		return 1;
 	}
 
 	double start = get_timestamp_millis();
 
 	int req_id = osrfAppSessionMakeRequest( session, params, method, 1, NULL );
+	jsonObjectFree(params);
 
-
 	osrf_message* omsg = osrfAppSessionRequestRecv( session, req_id, recv_timeout );
 
 	if(!omsg) 
@@ -603,7 +604,7 @@
 
 			if(omsg->_result_content) {
 	
-				osrf_message_free(last_result);
+				osrfMessageFree(last_result);
 				last_result = omsg;
 	
 				char* content;
@@ -639,7 +640,7 @@
 
 			if(omsg->_result_content) {
 	
-				osrf_message_free(last_result);
+				osrfMessageFree(last_result);
 				last_result = omsg;
 	
 				char* content;
@@ -832,7 +833,7 @@
 
 static int do_math( int count, int style ) {
 
-	osrfAppSession* session = osrf_app_client_session_init(  "opensrf.math" );
+	osrfAppSession* session = osrfAppSessionClientInit( "opensrf.math" );
 	osrf_app_session_connect(session);
 
 	jsonObject* params = jsonParseString("[]");
@@ -883,7 +884,7 @@
 				}
 
 
-				osrf_message_free(omsg);
+				osrfMessageFree(omsg);
 		
 			} else { fprintf( stderr, "\nempty message for tt: %d\n", req_id ); }
 



More information about the opensrf-commits mailing list