[open-ils-commits] r12183 - trunk/Open-ILS/src/c-apps (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Feb 14 21:40:41 EST 2009
Author: scottmk
Date: 2009-02-14 21:40:40 -0500 (Sat, 14 Feb 2009)
New Revision: 12183
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
1. in searchJOIN(): fixed a bug in a couple of loops that search for
links in the IDL. We were incrementing the index twice in each
iteration, and thereby examining only ever other entry.
2. Constified a couple of character pointers.
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-02-14 17:28:50 UTC (rev 12182)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-02-15 02:40:40 UTC (rev 12183)
@@ -2015,7 +2015,7 @@
working_hash = join_hash;
growing_buffer* join_buf = buffer_init(128);
- char* leftclass = osrfHashGet(leftmeta, "classname");
+ const char* leftclass = osrfHashGet(leftmeta, "classname");
jsonObject* snode = NULL;
jsonIterator* search_itr = jsonNewIterator( working_hash );
@@ -2025,7 +2025,7 @@
while ( (snode = jsonIteratorNext( search_itr )) ) {
osrfHash* idlClass = osrfHashGet( oilsIDL(), search_itr->key );
- char* class = osrfHashGet(idlClass, "classname");
+ const char* class = osrfHashGet(idlClass, "classname");
char* fkey = jsonObjectToSimpleString( jsonObjectGetKeyConst( snode, "fkey" ) );
char* field = jsonObjectToSimpleString( jsonObjectGetKeyConst( snode, "field" ) );
@@ -2070,14 +2070,13 @@
osrfHash* _links = oilsIDLFindPath("/%s/links", leftclass);
int i = 0;
+ const char* tmp_fkey;
osrfStringArray* keys = osrfHashKeys( _links );
- while ( (fkey = osrfStringArrayGetString(keys, i++)) ) {
- fkey = strdup(osrfStringArrayGetString(keys, i++));
- if ( !strcmp( (char*)oilsIDLFindPath("/%s/links/%s/class", leftclass, fkey), class) ) {
- field = strdup( (char*)oilsIDLFindPath("/%s/links/%s/key", leftclass, fkey) );
+ while ( (tmp_fkey = osrfStringArrayGetString(keys, i++)) ) {
+ if ( !strcmp( (char*)oilsIDLFindPath("/%s/links/%s/class", leftclass, tmp_fkey), class) ) {
+ field = strdup( (char*)oilsIDLFindPath("/%s/links/%s/key", leftclass, tmp_fkey) );
+ fkey = strdup(tmp_fkey);
break;
- } else {
- free(fkey);
}
}
osrfStringArrayFree(keys);
@@ -2086,14 +2085,13 @@
_links = oilsIDLFindPath("/%s/links", class);
i = 0;
+ const char* tmp_fld;
keys = osrfHashKeys( _links );
- while ( (field = osrfStringArrayGetString(keys, i++)) ) {
- field = strdup(osrfStringArrayGetString(keys, i++));
- if ( !strcmp( (char*)oilsIDLFindPath("/%s/links/%s/class", class, field), class) ) {
- fkey = strdup( (char*)oilsIDLFindPath("/%s/links/%s/key", class, field) );
+ while ( (tmp_fld = osrfStringArrayGetString(keys, i++)) ) {
+ if ( !strcmp( (char*)oilsIDLFindPath("/%s/links/%s/class", class, tmp_fld), class) ) {
+ fkey = strdup( (char*)oilsIDLFindPath("/%s/links/%s/key", class, tmp_fld) );
+ field = strdup( tmp_fld );
break;
- } else {
- free(field);
}
}
osrfStringArrayFree(keys);
@@ -2131,7 +2129,8 @@
free(type);
char* table = getSourceDefinition(idlClass);
- buffer_fadd(join_buf, " %s AS \"%s\" ON ( \"%s\".%s = \"%s\".%s", table, class, class, field, leftclass, fkey);
+ buffer_fadd(join_buf, " %s AS \"%s\" ON ( \"%s\".%s = \"%s\".%s",
+ table, class, class, field, leftclass, fkey);
free(table);
const jsonObject* filter = jsonObjectGetKeyConst( snode, "filter" );
More information about the open-ils-commits
mailing list