[open-ils-commits] r13502 - trunk/Open-ILS/src/c-apps (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Jul 5 08:47:12 EDT 2009


Author: scottmk
Date: 2009-07-05 08:47:11 -0400 (Sun, 05 Jul 2009)
New Revision: 13502

Modified:
   trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
Tweaks to osrfAppInitialize() in oils_cstore.c:

1. Move some invariant tests out of the inner loop.

2. Plugged a memory leak by freeing the array of class names.


Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-07-05 11:09:14 UTC (rev 13501)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-07-05 12:47:11 UTC (rev 13502)
@@ -187,6 +187,7 @@
     osrfLogDebug(OSRF_LOG_MARK,
 		"At least %d methods will be generated", classes->size * global_method_count);
 
+	// For each class in IDL...
     while ( (classname = osrfStringArrayGetString(classes, c_index++)) ) {
         osrfLogInfo(OSRF_LOG_MARK, "Generating class methods for %s", classname);
 
@@ -202,24 +203,29 @@
 			continue;
 		}
 
-        // Look up some other attributes of the current class
-        const char* idlClass_fieldmapper = osrfHashGet(idlClass, "fieldmapper");
-		const char* readonly = osrfHashGet(idlClass, "readonly");
+		// Look up some other attributes of the current class
+		const char* idlClass_fieldmapper = osrfHashGet(idlClass, "fieldmapper");
+		if( !idlClass_fieldmapper ) {
+			osrfLogDebug( OSRF_LOG_MARK, "Skipping class \"%s\"; no fieldmapper in IDL", classname );
+			continue;
+		}
+
 #ifdef PCRUD
-        osrfHash* idlClass_permacrud = osrfHashGet(idlClass, "permacrud");
+		osrfHash* idlClass_permacrud = osrfHashGet(idlClass, "permacrud");
+		if (!idlClass_permacrud) {
+			osrfLogDebug( OSRF_LOG_MARK, "Skipping class \"%s\"; no permacrud in IDL", classname );
+			continue;
+		}
 #endif
+		const char* readonly = osrfHashGet(idlClass, "readonly");
 
         int i;
-        for( i = 0; i < global_method_count; ++i ) {
+        for( i = 0; i < global_method_count; ++i ) {  // for each global method
             const char* method_type = global_method[ i ];
             osrfLogDebug(OSRF_LOG_MARK,
                 "Using files to build %s class methods for %s", method_type, classname);
 
-            if (!idlClass_fieldmapper) continue;
-
 #ifdef PCRUD
-            if (!idlClass_permacrud) continue;
-
             const char* tmp_method = method_type;
             if ( *tmp_method == 'i' || *tmp_method == 's') {
                 tmp_method = "retrieve";
@@ -275,9 +281,11 @@
                     );
 
             free(method);
-        }
-    }
+        } // end for each global method
+    } // end for each class in IDL
 
+	osrfStringArrayFree( classes );
+	
     return 0;
 }
 



More information about the open-ils-commits mailing list