[open-ils-commits] r8082 - trunk/Open-ILS/src/extras
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Nov 18 22:41:08 EST 2007
Author: miker
Date: 2007-11-18 22:23:44 -0500 (Sun, 18 Nov 2007)
New Revision: 8082
Modified:
trunk/Open-ILS/src/extras/oils_requestor.c
Log:
Patch from Scott McKellar to implement const-correctness, plug a recursion-based leak and move to the buffer_release() API
Modified: trunk/Open-ILS/src/extras/oils_requestor.c
===================================================================
--- trunk/Open-ILS/src/extras/oils_requestor.c 2007-11-18 17:43:39 UTC (rev 8081)
+++ trunk/Open-ILS/src/extras/oils_requestor.c 2007-11-19 03:23:44 UTC (rev 8082)
@@ -12,7 +12,7 @@
char* authtoken = NULL;
static int do_request( char* request );
-static char* format_response( jsonObject* o );
+static char* format_response( const jsonObject* o );
int main( int argc, char* argv[] ) {
@@ -87,8 +87,8 @@
if(!strcmp(request,"")) return 0;
- char* service;
- char* method;
+ const char* service;
+ const char* method;
char* tmp;
service = strtok_r(request, " ", &tmp);
@@ -106,7 +106,7 @@
}
osrfAppSession* session = osrf_app_client_session_init(service);
- int req_id = osrf_app_session_make_req( session, params, method, 1, NULL );
+ int req_id = osrfAppSessionMakeRequest( session, params, method, 1, NULL );
osrfMessage* omsg;
while( (omsg = osrfAppSessionRequestRecv( session, req_id, 120 )) ) {
@@ -128,7 +128,7 @@
}
-static char* format_response( jsonObject* o ) {
+static char* format_response( const jsonObject* o ) {
if(!o) return NULL;
int width = 20;
@@ -143,7 +143,7 @@
while( (key = fm_pton(o->classname, i++)) ) {
char* val = oilsFMGetString(o, key);
- jsonObject* item;
+ const jsonObject* item;
int l = strlen(key + 2);
buffer_fadd(buffer, " %s: ", key);
@@ -176,9 +176,7 @@
free(key);
}
- char* data = buffer_data(buffer);
- buffer_free(buffer);
- return data;
+ return buffer_release(buffer);
}
char* jjson;
@@ -188,10 +186,10 @@
for( i = 0; i != o->size; i++ ) {
char* d = format_response(jsonObjectGetIndex(o, i));
buffer_fadd(arrb, "%s\n", d);
+ free(d);
}
- jjson = buffer_data(arrb);
- buffer_free(arrb);
+ jjson = buffer_release(arrb);
} else {
char* json = jsonObjectToJSON(o);
More information about the open-ils-commits
mailing list