moving around itr definitions ... something has made json_query unhappy recently
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 9 Dec 2007 03:18:28 +0000 (03:18 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 9 Dec 2007 03:18:28 +0000 (03:18 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@8176 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 648dcc6..f58e900 100644 (file)
@@ -1978,9 +1978,9 @@ static char* SELECT (
                if (!jsonObjectGetKeyConst(selhash,snode->key))
                        continue;
 
+               jsonObjectIterator* order_itr = jsonNewObjectIterator( snode->item );
                if ( snode->item->type == JSON_HASH ) {
 
-                       jsonObjectIterator* order_itr = jsonNewObjectIterator( snode->item );
                        while ( (onode = jsonObjectIteratorNext( order_itr )) ) {
 
                                if (!oilsIDLFindPath( "/%s/fields/%s", snode->key, onode->key ))
@@ -2038,11 +2038,8 @@ static char* SELECT (
 
                        }
 
-            jsonObjectIteratorFree(order_itr);
-
                } else if ( snode->item->type == JSON_ARRAY ) {
 
-                       jsonObjectIterator* order_itr = jsonNewObjectIterator( snode->item );
                        while ( (onode = jsonObjectIteratorNext( order_itr )) ) {
 
                                char* _f = jsonObjectToSimpleString( onode->item );
@@ -2061,7 +2058,6 @@ static char* SELECT (
 
                        }
 
-            jsonObjectIteratorFree(order_itr);
 
                // IT'S THE OOOOOOOOOOOLD STYLE!
                } else {
@@ -2079,10 +2075,13 @@ static char* SELECT (
                        buffer_free(group_buf);
                        buffer_free(order_buf);
                        buffer_free(sql_buf);
+            jsonObjectIteratorFree(order_itr);
                        if (defaultselhash) jsonObjectFree(defaultselhash);
                        return NULL;
                }
 
+        jsonObjectIteratorFree(order_itr);
+
        }
 
     jsonObjectIteratorFree(class_itr);