X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-record-cache.c;h=ea21312ce81b82c121442f40dca63f4b28585cf1;hp=75b3945ae08653fa93eac1ba027abaace2db8a59;hb=176adcd5ec7f2340fb6f0f625a727498db9c04c4;hpb=0c46d2e66bdeea1600e700124a81a5d0a65d349e diff --git a/src/zoom-record-cache.c b/src/zoom-record-cache.c index 75b3945..ea21312 100644 --- a/src/zoom-record-cache.c +++ b/src/zoom-record-cache.c @@ -49,16 +49,6 @@ struct ZOOM_record_cache_p { ZOOM_record_cache next; }; - -static int strcmp_null(const char *v1, const char *v2) -{ - if (!v1 && !v2) - return 0; - if (!v1 || !v2) - return -1; - return strcmp(v1, v2); -} - static size_t record_hash(int pos) { if (pos < 0) @@ -80,9 +70,9 @@ void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr, for (rc = r->record_hash[record_hash(pos)]; rc; rc = rc->next) { if (pos == rc->pos - && strcmp_null(r->schema, rc->schema) == 0 - && strcmp_null(elementSetName,rc->elementSetName) == 0 - && strcmp_null(syntax, rc->syntax) == 0) + && yaz_strcmp_null(schema, rc->schema) == 0 + && yaz_strcmp_null(elementSetName,rc->elementSetName) == 0 + && yaz_strcmp_null(syntax, rc->syntax) == 0) break; } if (!rc) @@ -99,7 +89,7 @@ void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr, rc->syntax = odr_strdup_null(r->odr, syntax); - rc->schema = odr_strdup_null(r->odr, r->schema); + rc->schema = odr_strdup_null(r->odr, schema); rc->pos = pos; rc->next = r->record_hash[record_hash(pos)]; @@ -128,7 +118,8 @@ void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr, ZOOM_record ZOOM_record_cache_lookup(ZOOM_resultset r, int pos, const char *syntax, - const char *elementSetName) + const char *elementSetName, + const char *schema) { ZOOM_record_cache rc; @@ -136,11 +127,11 @@ ZOOM_record ZOOM_record_cache_lookup(ZOOM_resultset r, int pos, { if (pos == rc->pos) { - if (strcmp_null(r->schema, rc->schema)) + if (yaz_strcmp_null(schema, rc->schema)) continue; - if (strcmp_null(elementSetName,rc->elementSetName)) + if (yaz_strcmp_null(elementSetName,rc->elementSetName)) continue; - if (strcmp_null(syntax, rc->syntax)) + if (yaz_strcmp_null(syntax, rc->syntax)) continue; return &rc->rec; }