X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzinfo.c;h=a61dac1bd68e975411a7220c272c9f6b33a5d920;hb=3168ab325caf86d3bac38c33f7d3b701d1110539;hp=b474306016b76c0a322c0fef9a3f6dd105047d69;hpb=4d7345f0e28b1e56658c26a31ffaee95dcf502c0;p=idzebra-moved-to-github.git diff --git a/index/zinfo.c b/index/zinfo.c index b474306..a61dac1 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,4 +1,4 @@ -/* $Id: zinfo.c,v 1.55 2006-02-20 12:41:42 adam Exp $ +/* $Id: zinfo.c,v 1.57 2006-03-30 09:52:15 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -150,11 +150,15 @@ static Record createRecord(Records records, SYSNO *sysno) if (*sysno) { rec = rec_get(records, *sysno); + if (!rec) + return 0; xfree(rec->info[recInfo_storeData]); } else { rec = rec_new(records); + if (!rec) + return 0; *sysno = rec->sysno; rec->info[recInfo_fileType] = @@ -520,6 +524,12 @@ ZebraExplainInfo zebraExplain_open( /* write now because we want to be sure about the sysno */ trec = rec_new(records); + if (!trec) + { + yaz_log(YLOG_FATAL, "Cannot create root Explain record"); + nmem_destroy(zei->nmem); + return 0; + } trec->info[recInfo_fileType] = rec_strdup("grs.sgml", &trec->size[recInfo_fileType]); trec->info[recInfo_databaseName] = @@ -529,11 +539,11 @@ ZebraExplainInfo zebraExplain_open( trec->info[recInfo_storeData] = (char *) xmalloc(sgml_len); memcpy(trec->info[recInfo_storeData], sgml_buf, sgml_len); trec->size[recInfo_storeData] = sgml_len; - + rec_put(records, &trec); rec_rm(&trec); - } + zebraExplain_newDatabase(zei, "IR-Explain-1", 0); if (!zei->categoryList->dirty) @@ -986,6 +996,8 @@ static void zebraExplain_writeCategoryList (ZebraExplainInfo zei, #endif drec = createRecord (zei->records, &sysno); + if (!drec) + return; node_ci = data1_search_tag (zei->dh, node_categoryList, "/categoryList"); @@ -1040,6 +1052,8 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, #endif drec = createRecord (zei->records, &zad->sysno); + if (!drec) + return; assert (zad->data1_tree); node_adinfo = data1_search_tag (zei->dh, zad->data1_tree, @@ -1182,6 +1196,8 @@ static void zebraExplain_writeDatabase (ZebraExplainInfo zei, yaz_log(YLOG_LOG, "zebraExplain_writeDatabase %s", zdi->databaseName); #endif drec = createRecord (zei->records, &zdi->sysno); + if (!drec) + return; assert (zdi->data1_database); node_dbinfo = data1_search_tag (zei->dh, zdi->data1_database, @@ -1272,6 +1288,8 @@ static void zebraExplain_writeAttributeSet (ZebraExplainInfo zei, #endif drec = createRecord (zei->records, &o->sysno); + if (!drec) + return; node_root = data1_read_sgml (zei->dh, zei->nmem, "AttributeSetInfo\n" @@ -1445,9 +1463,20 @@ int zebraExplain_trav_ord(ZebraExplainInfo zei, void *handle, int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord, int *index_type, const char **db, - int *set, int *use) + int *set, int *use, + const char **string_index) { struct zebDatabaseInfoB *zdb; + + if (set) + *set = -1; + if (use) + *use = -1; + if (index_type) + *index_type = 0; + if (string_index) + *string_index = 0; + for (zdb = zei->databaseInfo; zdb; zdb = zdb->next) { struct zebSUInfoB *zsui; @@ -1467,6 +1496,11 @@ int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord, if (use) *use = zsui->info.u.su.use; } + + if (zsui->info.which == ZEB_SU_STR) + if (string_index) + *string_index = zsui->info.u.str; + if (index_type) *index_type = zsui->info.index_type; return 0;