freeing iterators after use
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 9 Dec 2007 02:50:54 +0000 (02:50 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 9 Dec 2007 02:50:54 +0000 (02:50 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@8175 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/oils_cstore.c

index e087dc8..648dcc6 100644 (file)
@@ -661,6 +661,7 @@ int dispatchCRUDMethod ( osrfMethodContext* ctx ) {
                free(_s);
 
                obj = doFieldmapperSearch(ctx, class_obj, _p, &err);
+               jsonObjectFree(_p);
                if(err) return err;
 
                jsonObjectNode* cur;
@@ -1321,6 +1322,7 @@ static char* searchPredicate ( const char* class, osrfHash* field, jsonObject* n
 
                        break;
                }
+        jsonObjectIteratorFree(pred_itr);
        } else if (node->type == JSON_NULL) { // IS NULL search
                growing_buffer* _p = buffer_init(64);
                buffer_fadd(
@@ -1530,6 +1532,8 @@ static char* searchJOIN ( const jsonObject* join_hash, osrfHash* leftmeta ) {
                free(field);
        }
 
+    jsonObjectIteratorFree(search_itr);
+
        return buffer_release(join_buf);
 }
 
@@ -1807,7 +1811,7 @@ static char* SELECT (
                            char* pkey = osrfHashGet(idlClass, "primarykey");
                            char* tname = osrfHashGet(idlClass, "tablename");
 
-                           buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, __column, pkey, cname, pkey, locale, __column);
+                        buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, __column, pkey, cname, pkey, locale, __column);
                     } else {
                                        buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, __column, __column);
                     }
@@ -1851,7 +1855,7 @@ static char* SELECT (
                                char* pkey = osrfHashGet(idlClass, "primarykey");
                                char* tname = osrfHashGet(idlClass, "tablename");
 
-                               buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, fname, pkey, cname, pkey, locale, __alias);
+                            buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, fname, pkey, cname, pkey, locale, __alias);
                         } else {
                                                buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, fname, __alias);
                         }
@@ -1891,8 +1895,11 @@ static char* SELECT (
 
                        sel_pos++;
                }
+        jsonObjectIteratorFree(select_itr);
        }
 
+    jsonObjectIteratorFree(selclass_itr);
+
        if (is_agg) jsonObjectFree(is_agg);
 
        char* col_list = buffer_release(select_buf);
@@ -2031,6 +2038,8 @@ static char* SELECT (
 
                        }
 
+            jsonObjectIteratorFree(order_itr);
+
                } else if ( snode->item->type == JSON_ARRAY ) {
 
                        jsonObjectIterator* order_itr = jsonNewObjectIterator( snode->item );
@@ -2052,6 +2061,8 @@ static char* SELECT (
 
                        }
 
+            jsonObjectIteratorFree(order_itr);
+
                // IT'S THE OOOOOOOOOOOLD STYLE!
                } else {
                        osrfLogError(OSRF_LOG_MARK, "%s: Possible SQL injection attempt; direct order by is not allowed", MODULENAME);
@@ -2074,6 +2085,8 @@ static char* SELECT (
 
        }
 
+    jsonObjectIteratorFree(class_itr);
+
        string = buffer_release(group_buf);
 
        if (strlen(string)) {
@@ -2212,7 +2225,7 @@ static char* buildSELECT ( jsonObject* search_hash, jsonObject* order_hash, osrf
                        char* pkey = osrfHashGet(idlClass, "primarykey");
                        char* tname = osrfHashGet(idlClass, "tablename");
 
-                           buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, fname, pkey, cname, pkey, locale, fname);
+                    buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, fname, pkey, cname, pkey, locale, fname);
                 } else {
                                buffer_fadd(select_buf, " \"%s\".%s", cname, fname);
                 }
@@ -2220,8 +2233,12 @@ static char* buildSELECT ( jsonObject* search_hash, jsonObject* order_hash, osrf
                            buffer_fadd(select_buf, " \"%s\".%s", cname, fname);
             }
                }
+
+        jsonObjectIteratorFree(select_itr);
        }
 
+    jsonObjectIteratorFree(class_itr);
+
        char* col_list = buffer_release(select_buf);
        char* table = getSourceDefinition(meta);
 
@@ -2330,6 +2347,8 @@ static char* buildSELECT ( jsonObject* search_hash, jsonObject* order_hash, osrf
 
                                        }
 
+                    jsonObjectIteratorFree(order_itr);
+
                                } else {
                                        string = jsonObjectToSimpleString(snode->item);
                                        buffer_add(order_buf, string);
@@ -2339,6 +2358,8 @@ static char* buildSELECT ( jsonObject* search_hash, jsonObject* order_hash, osrf
 
                        }
 
+            jsonObjectIteratorFree(class_itr);
+
                        string = buffer_release(order_buf);
 
                        if (strlen(string)) {
@@ -2555,6 +2576,7 @@ static jsonObject* doFieldmapperSearch ( osrfMethodContext* ctx, osrfHash* meta,
                                                while ((_f = jsonObjectIteratorNext( _i ))) {
                                                        osrfStringArrayAdd( link_fields, jsonObjectToSimpleString( _f->item ) );
                                                }
+                        jsonObjectIteratorFree(_i);
                                        }
                                }