X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-z-cache.cpp;h=5277a0dbe86103492512938f33349550e386b881;hb=0499c317de03b020469f3122c8a1cee8bc459389;hp=90c3c4b858a050de4c10bffb2bb9aa81c72eba7a;hpb=7411ed6df7fc0b535f83503f73d70e80f390e295;p=yazpp-moved-to-github.git diff --git a/src/yaz-z-cache.cpp b/src/yaz-z-cache.cpp index 90c3c4b..5277a0d 100644 --- a/src/yaz-z-cache.cpp +++ b/src/yaz-z-cache.cpp @@ -1,13 +1,12 @@ -/* - * Copyright (c) 2002-2004, Index Data. +/* This file is part of the yazpp toolkit. + * Copyright (C) 1998-2009 Index Data and Mike Taylor * See the file LICENSE for details. - * - * $Id: yaz-z-cache.cpp,v 1.14 2005-06-25 15:53:19 adam Exp $ */ #include #include -#include +#include +#include using namespace yazpp_1; @@ -86,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) { @@ -108,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; @@ -217,6 +208,7 @@ int RecordCache::lookup (ODR o, Z_NamePlusRecordList **npr, /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab