X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-z-cache.cpp;h=11544b3ca4d57b145be02071c577fc753097179c;hb=8353663886b90d762d43790780be6cb58fb93c8a;hp=9c3eab6efdcd9690d7f7b996ca2e2a461e509884;hpb=6b22d0543d41bec8626f3ae7ac866bcab7de44bd;p=yazpp-moved-to-github.git diff --git a/src/yaz-z-cache.cpp b/src/yaz-z-cache.cpp index 9c3eab6..11544b3 100644 --- a/src/yaz-z-cache.cpp +++ b/src/yaz-z-cache.cpp @@ -1,10 +1,11 @@ /* This file is part of the yazpp toolkit. - * Copyright (C) 1998-2009 Index Data and Mike Taylor + * Copyright (C) 1998-2011 Index Data and Mike Taylor * See the file LICENSE for details. */ #include #include +#include #include using namespace yazpp_1; @@ -30,7 +31,7 @@ RecordCache::~RecordCache () nmem_destroy(m_mem); } -void RecordCache::set_max_size(int sz) +void RecordCache::set_max_size(size_t sz) { m_max_size = sz; } @@ -84,6 +85,7 @@ void RecordCache::copy_presentRequest(Z_PresentRequest *pr) odr_destroy(decode); } + void RecordCache::add (ODR o, Z_NamePlusRecordList *npr, int start, int hits) { @@ -106,23 +108,14 @@ void RecordCache::add (ODR o, Z_NamePlusRecordList *npr, int start, comp->u.simple = esn; } - // Z_NamePlusRecordList *npr to be owned by m_mem.. - NMEM tmp_mem = odr_extract_mem(o); - nmem_transfer(m_mem, tmp_mem); - nmem_destroy(tmp_mem); - // Insert individual records in cache int i; for (i = 0; inum_records; i++) { RecordCache_Entry *entry = (RecordCache_Entry *) nmem_malloc(m_mem, sizeof(*entry)); - entry->m_record = (Z_NamePlusRecord *) - nmem_malloc(m_mem, sizeof(*entry->m_record)); - entry->m_record->databaseName = npr->records[i]->databaseName; - entry->m_record->which = npr->records[i]->which; - entry->m_record->u.databaseRecord = npr->records[i]->u.databaseRecord; - entry->m_comp = comp; + entry->m_record = yaz_clone_z_NamePlusRecord(npr->records[i], m_mem); + entry->m_comp = yaz_clone_z_RecordComposition(comp, m_mem); entry->m_offset = i + start; entry->m_next = m_entries; m_entries = entry;