Patch from Scott McKellar:
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 31 Jan 2008 19:12:40 +0000 (19:12 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 31 Jan 2008 19:12:40 +0000 (19:12 +0000)
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

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1237 9efc2488-bf62-4759-914b-345cdb29e865

src/srfsh/srfsh.c

index ae34af5..ddf242e 100644 (file)
@@ -557,29 +557,30 @@ int send_request( char* server,
                        return 1;
                }
                else {
                        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");
                }
        }
 
 
        if(buffer->n_used > 0 && params == NULL) {
                fprintf(stderr, "JSON error detected, not executing\n");
+               jsonObjectFree(params);
                return 1;
        }
 
                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 );
 
        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 );
                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 );
 
 
        osrf_message* omsg = osrfAppSessionRequestRecv( session, req_id, recv_timeout );
 
@@ -603,7 +604,7 @@ int send_request( char* server,
 
                        if(omsg->_result_content) {
        
 
                        if(omsg->_result_content) {
        
-                               osrf_message_free(last_result);
+                               osrfMessageFree(last_result);
                                last_result = omsg;
        
                                char* content;
                                last_result = omsg;
        
                                char* content;
@@ -639,7 +640,7 @@ int send_request( char* server,
 
                        if(omsg->_result_content) {
        
 
                        if(omsg->_result_content) {
        
-                               osrf_message_free(last_result);
+                               osrfMessageFree(last_result);
                                last_result = omsg;
        
                                char* content;
                                last_result = omsg;
        
                                char* content;
@@ -832,7 +833,7 @@ static int handle_math( char* words[] ) {
 
 static int do_math( int count, int style ) {
 
 
 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("[]");
        osrf_app_session_connect(session);
 
        jsonObject* params = jsonParseString("[]");
@@ -883,7 +884,7 @@ static int do_math( int count, int style ) {
                                }
 
 
                                }
 
 
-                               osrf_message_free(omsg);
+                               osrfMessageFree(omsg);
                
                        } else { fprintf( stderr, "\nempty message for tt: %d\n", req_id ); }
 
                
                        } else { fprintf( stderr, "\nempty message for tt: %d\n", req_id ); }