~ubuntu-branches/ubuntu/precise/yazpp/precise

« back to all changes in this revision

Viewing changes to src/yaz-z-cache.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-09-24 20:56:47 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100924205647-lqs18dn7ectxo3ql
Tags: 1.2.3-0ubuntu1
New upstream version, required to build with yaz 4.0.x. LP: #647079.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* This file is part of the yazpp toolkit.
2
 
 * Copyright (C) 1998-2008 Index Data and Mike Taylor
 
2
 * Copyright (C) 1998-2010 Index Data and Mike Taylor
3
3
 * See the file LICENSE for details.
4
4
 */
5
5
 
6
6
#include <yaz/log.h>
7
7
#include <yaz/proto.h>
 
8
#include <yaz/copy_types.h>
8
9
#include <yazpp/record-cache.h>
9
10
 
10
11
using namespace yazpp_1;
30
31
    nmem_destroy(m_mem);
31
32
}
32
33
 
33
 
void RecordCache::set_max_size(int sz)
 
34
void RecordCache::set_max_size(size_t sz)
34
35
{
35
36
    m_max_size = sz;
36
37
}
84
85
    odr_destroy(decode);
85
86
}
86
87
 
 
88
 
87
89
void RecordCache::add (ODR o, Z_NamePlusRecordList *npr, int start,
88
90
                           int hits)
89
91
{
106
108
        comp->u.simple = esn;
107
109
    }
108
110
 
109
 
    // Z_NamePlusRecordList *npr to be owned by m_mem..
110
 
    NMEM tmp_mem = odr_extract_mem(o);
111
 
    nmem_transfer(m_mem, tmp_mem);
112
 
    nmem_destroy(tmp_mem);
113
 
    
114
111
    // Insert individual records in cache
115
112
    int i;
116
113
    for (i = 0; i<npr->num_records; i++)
117
114
    {
118
115
        RecordCache_Entry *entry = (RecordCache_Entry *)
119
116
            nmem_malloc(m_mem, sizeof(*entry));
120
 
        entry->m_record = (Z_NamePlusRecord *)
121
 
            nmem_malloc(m_mem, sizeof(*entry->m_record));
122
 
        entry->m_record->databaseName = npr->records[i]->databaseName;
123
 
        entry->m_record->which = npr->records[i]->which;
124
 
        entry->m_record->u.databaseRecord  = npr->records[i]->u.databaseRecord;
125
 
        entry->m_comp = comp;
 
117
        entry->m_record = yaz_clone_z_NamePlusRecord(npr->records[i], m_mem);
 
118
        entry->m_comp = yaz_clone_z_RecordComposition(comp, m_mem);
126
119
        entry->m_offset = i + start;
127
120
        entry->m_next = m_entries;
128
121
        m_entries = entry;
215
208
/*
216
209
 * Local variables:
217
210
 * c-basic-offset: 4
 
211
 * c-file-style: "Stroustrup"
218
212
 * indent-tabs-mode: nil
219
213
 * End:
220
214
 * vim: shiftwidth=4 tabstop=8 expandtab