-/* $Id: recindex.c,v 1.53 2006-11-14 08:12:08 adam Exp $
- Copyright (C) 1995-2006
+/* $Id: recindex.c,v 1.56 2007-01-15 15:10:17 adam Exp $
+ Copyright (C) 1995-2007
Index Data ApS
This file is part of the Zebra server.
#define USUAL_RANGE 2000000000LL
#endif
-static SYSNO rec_sysno_to_ext(SYSNO sysno)
+static zint rec_sysno_to_ext(zint sysno)
{
assert(sysno >= 0 && sysno <= USUAL_RANGE);
return sysno + FAKE_OFFSET;
}
-SYSNO rec_sysno_to_int(SYSNO sysno)
+zint rec_sysno_to_int(zint sysno)
{
assert(sysno >= FAKE_OFFSET && sysno <= FAKE_OFFSET + USUAL_RANGE);
return sysno - FAKE_OFFSET;
}
}
-static int read_indx(Records p, SYSNO sysno, void *buf, int itemsize,
+static int read_indx(Records p, zint sysno, void *buf, int itemsize,
int ignoreError)
{
int r;
return r;
}
-static void write_indx(Records p, SYSNO sysno, void *buf, int itemsize)
+static void write_indx(Records p, zint sysno, void *buf, int itemsize)
{
zint pos = (sysno-1)*itemsize;
int off = CAST_ZINT_TO_INT(pos%RIDX_CHUNK);
(char*) buf + sz1);
}
-static ZEBRA_RES rec_release_blocks(Records p, SYSNO sysno)
+static ZEBRA_RES rec_release_blocks(Records p, zint sysno)
{
struct record_index_entry entry;
zint freeblock;
{
struct record_index_entry entry;
+ /* all data in entry must be reset, since it's written verbatim */
+ memset(&entry, '\0', sizeof(entry));
if (rec_release_blocks(p, rec_sysno_to_int(rec->sysno)) != ZEBRA_OK)
return ZEBRA_FAIL;
return ZEBRA_OK;
}
-static ZEBRA_RES rec_write_tmp_buf(Records p, int size, SYSNO *sysnos)
+static ZEBRA_RES rec_write_tmp_buf(Records p, int size, zint *sysnos)
{
struct record_index_entry entry;
int no_written = 0;
int dst_type = 0;
int i;
+ /* all data in entry must be reset, since it's written verbatim */
+ memset(&entry, '\0', sizeof(entry));
+
for (i = 1; i<REC_BLOCK_TYPES; i++)
if (size >= p->head.block_move[i])
dst_type = i;
ZEBRA_RES ret = ZEBRA_OK;
p = (Records) xmalloc(sizeof(*p));
+ memset(&p->head, '\0', sizeof(p->head));
p->compression_method = compression_method;
p->rw = rw;
p->tmp_size = 1024;
int out_size = 1000;
int out_offset = 0;
char *out_buf = (char *) xmalloc(out_size);
- SYSNO *sysnos = (SYSNO *) xmalloc(sizeof(*sysnos) * (p->cache_cur + 1));
- SYSNO *sysnop = sysnos;
+ zint *sysnos = (zint *) xmalloc(sizeof(*sysnos) * (p->cache_cur + 1));
+ zint *sysnop = sysnos;
ZEBRA_RES ret = ZEBRA_OK;
for (i = 0; i<p->cache_cur - saveCount; i++)
return ret;
}
-static Record *rec_cache_lookup(Records p, SYSNO sysno,
+static Record *rec_cache_lookup(Records p, zint sysno,
enum recordCacheFlag flag)
{
int i;
return ret;
}
-static Record rec_get_int(Records p, SYSNO sysno)
+static Record rec_get_int(Records p, zint sysno)
{
int i, in_size, r;
Record rec, *recp;
return rec;
}
-Record rec_get(Records p, SYSNO sysno)
+Record rec_get(Records p, zint sysno)
{
Record rec;
zebra_mutex_lock(&p->mutex);
static Record rec_new_int(Records p)
{
int i;
- SYSNO sysno;
+ zint sysno;
Record rec;
assert(p);