[open-ils-commits] r8551 - trunk/Open-ILS/src/c-apps
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jan 31 15:21:06 EST 2008
Author: miker
Date: 2008-01-31 14:53:27 -0500 (Thu, 31 Jan 2008)
New Revision: 8551
Modified:
trunk/Open-ILS/src/c-apps/oils_utils.c
Log:
Patch from Scott McKellar:
1. In oilsInitIDL: I added the const qualifier to the input parameter.
This change involved some juggling of a couple of extra variables.
2. Also in oilsInitIDL: I plugged a potential memory leak related to
an early return.
3. In oilsUtilsFetchUserByBarcode we create a jsonObject named
"card" but we weren't freeing it. Now we free it.
Modified: trunk/Open-ILS/src/c-apps/oils_utils.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_utils.c 2008-01-31 19:01:25 UTC (rev 8550)
+++ trunk/Open-ILS/src/c-apps/oils_utils.c 2008-01-31 19:53:27 UTC (rev 8551)
@@ -1,27 +1,32 @@
#include "openils/oils_utils.h"
#include "openils/oils_idl.h"
-osrfHash* oilsInitIDL(char* idl_filename) {
+osrfHash* oilsInitIDL(const char* idl_filename) {
- int freeme = 0;
- if(!idl_filename) {
- idl_filename = osrf_settings_host_value("/IDL");
- freeme = 1;
- }
+ char* freeable_filename = NULL;
+ const char* filename;
- if (!idl_filename) {
+ if(idl_filename)
+ filename = idl_filename;
+ else {
+ freeable_filename = osrf_settings_host_value("/IDL");
+ filename = freeable_filename;
+ }
+
+ if (!filename) {
osrfLogError(OSRF_LOG_MARK, "No settings config for '/IDL'");
return NULL;
}
- osrfLogInfo(OSRF_LOG_MARK, "Parsing IDL %s", idl_filename);
+ osrfLogInfo(OSRF_LOG_MARK, "Parsing IDL %s", filename);
- if (!oilsIDLInit( idl_filename )) {
- osrfLogError(OSRF_LOG_MARK, "Problem loading IDL file [%s]!", idl_filename);
+ if (!oilsIDLInit( filename )) {
+ osrfLogError(OSRF_LOG_MARK, "Problem loading IDL file [%s]!", filename);
+ if(freeable_filename) free(freeable_filename);
return NULL;
}
- if(freeme) free(idl_filename);
+ if(freeable_filename) free(freeable_filename);
return oilsIDL();
}
@@ -143,6 +148,7 @@
if(!card) { jsonObjectFree(params); return NULL; }
char* usr = oilsFMGetString(card, "usr");
+ jsonObjectFree(card);
if(!usr) return NULL;
double iusr = strtod(usr, NULL);
free(usr);
More information about the open-ils-commits
mailing list