X-Git-Url: http://git.indexdata.com/?p=yazpp-moved-to-github.git;a=blobdiff_plain;f=src%2Fyaz-z-cache.cpp;fp=src%2Fyaz-z-cache.cpp;h=f023924d8170fd79abad786cae094987cc594833;hp=6c283ac232d859fd4c130fafc6e7776f159771d3;hb=d54b824ca309141da489284e5b6d78d7094f5494;hpb=24e9fcd6b54f6d07db66d71743e9a71aaaf4a90f diff --git a/src/yaz-z-cache.cpp b/src/yaz-z-cache.cpp index 6c283ac..f023924 100644 --- a/src/yaz-z-cache.cpp +++ b/src/yaz-z-cache.cpp @@ -100,12 +100,29 @@ void RecordCache::copy_presentRequest(Z_PresentRequest *pr) odr_destroy(decode); } - void RecordCache::add(ODR o, Z_NamePlusRecordList *npr, int start, - int hits) + Z_RecordComposition *comp) { if (nmem_total(m_p->nmem) > m_p->max_size) return; + // Insert individual records in cache + int i; + for (i = 0; i < npr->num_records; i++) + { + RecordCache_Entry *entry = (RecordCache_Entry *) + nmem_malloc(m_p->nmem, sizeof(*entry)); + entry->m_record = + yaz_clone_z_NamePlusRecord(npr->records[i], m_p->nmem); + entry->m_comp = yaz_clone_z_RecordComposition(comp, m_p->nmem); + entry->m_offset = i + start; + entry->m_next = m_p->entries; + m_p->entries = entry; + } +} + +void RecordCache::add(ODR o, Z_NamePlusRecordList *npr, int start, + int hits) +{ // Build appropriate compspec for this response Z_RecordComposition *comp = 0; if (hits == -1 && m_p->presentRequest) @@ -122,20 +139,7 @@ void RecordCache::add(ODR o, Z_NamePlusRecordList *npr, int start, comp->which = Z_RecordComp_simple; comp->u.simple = esn; } - - // Insert individual records in cache - int i; - for (i = 0; inum_records; i++) - { - RecordCache_Entry *entry = (RecordCache_Entry *) - nmem_malloc(m_p->nmem, sizeof(*entry)); - entry->m_record = - yaz_clone_z_NamePlusRecord(npr->records[i], m_p->nmem); - entry->m_comp = yaz_clone_z_RecordComposition(comp, m_p->nmem); - entry->m_offset = i + start; - entry->m_next = m_p->entries; - m_p->entries = entry; - } + add(o, npr, start, comp); } int RecordCache::Rep::match(RecordCache_Entry *entry,