From: miker Date: Sun, 9 Dec 2007 01:57:43 +0000 (+0000) Subject: free returned objects in json_query X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ea1729b98eb935b61ee3ca3048bc3c1e3284d788;p=Evergreen.git free returned objects in json_query git-svn-id: svn://svn.open-ils.org/ILS/trunk@8174 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c index ac33abbd51..e087dc8598 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -637,7 +637,7 @@ int dispatchCRUDMethod ( osrfMethodContext* ctx ) { jsonObjectNode* cur; jsonObjectIterator* itr = jsonNewObjectIterator( obj ); while ((cur = jsonObjectIteratorNext( itr ))) { - osrfAppRespond( ctx, jsonObjectClone(cur->item) ); + osrfAppRespond( ctx, cur->item ); } jsonObjectIteratorFree(itr); osrfAppRespondComplete( ctx, NULL ); @@ -668,17 +668,15 @@ int dispatchCRUDMethod ( osrfMethodContext* ctx ) { while ((cur = jsonObjectIteratorNext( itr ))) { osrfAppRespond( ctx, - jsonObjectClone( - jsonObjectGetIndex( - cur->item, - atoi( + jsonObjectGetIndex( + cur->item, + atoi( + osrfHashGet( osrfHashGet( - osrfHashGet( - osrfHashGet( class_obj, "fields" ), - osrfHashGet( class_obj, "primarykey") - ), - "array_position" - ) + osrfHashGet( class_obj, "fields" ), + osrfHashGet( class_obj, "primarykey") + ), + "array_position" ) ) ) @@ -2430,7 +2428,9 @@ int doJSONSearch ( osrfMethodContext* ctx ) { osrfLogDebug(OSRF_LOG_MARK, "Query returned at least one row"); do { - osrfAppRespond( ctx, oilsMakeJSONFromResult( result ) ); + jsonObject* return_val = oilsMakeJSONFromResult( result ); + osrfAppRespond( ctx, return_val ); + jsonObjectFree( return_val ); } while (dbi_result_next_row(result)); } else { @@ -3026,7 +3026,7 @@ static jsonObject* doDelete(osrfMethodContext* ctx, int* err ) { static jsonObject* oilsMakeFieldmapperFromResult( dbi_result result, osrfHash* meta) { if(!(result && meta)) return jsonNULL; - jsonObject* object = jsonParseString("[]"); + jsonObject* object = jsonNewObject(NULL); jsonObjectSetClass(object, osrfHashGet(meta, "classname")); osrfHash* fields = osrfHashGet(meta, "fields"); @@ -3136,7 +3136,7 @@ static jsonObject* oilsMakeFieldmapperFromResult( dbi_result result, osrfHash* m static jsonObject* oilsMakeJSONFromResult( dbi_result result ) { if(!result) return jsonNULL; - jsonObject* object = jsonParseString("{}"); + jsonObject* object = jsonNewObject(NULL); time_t _tmp_dt; char dt_string[256];