-/* $Id: recindex.c,v 1.48 2006-05-10 08:13:22 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: recindex.c,v 1.50 2006-06-07 10:14:41 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
{
int r;
zint pos = (sysno-1)*itemsize;
- int off = (int) (pos%RIDX_CHUNK);
+ int off = CAST_ZINT_TO_INT(pos%RIDX_CHUNK);
int sz1 = RIDX_CHUNK - off; /* sz1 is size of buffer to read.. */
if (sz1 > itemsize)
static void write_indx(Records p, SYSNO sysno, void *buf, int itemsize)
{
zint pos = (sysno-1)*itemsize;
- int off = (int) (pos%RIDX_CHUNK);
+ int off = CAST_ZINT_TO_INT(pos%RIDX_CHUNK);
int sz1 = RIDX_CHUNK - off; /* sz1 is size of buffer to read.. */
if (sz1 > itemsize)
freeblock = entry.next;
assert(freeblock > 0);
- dst_type = (int) (freeblock & 7);
+ dst_type = CAST_ZINT_TO_INT(freeblock & 7);
assert(dst_type < REC_BLOCK_TYPES);
freeblock = freeblock / 8;
while (freeblock)
cptr = p->tmp_buf + no_written;
}
block_prev = block_free;
- no_written += (int)(p->head.block_size[dst_type]) - sizeof(zint);
+ no_written += CAST_ZINT_TO_INT(p->head.block_size[dst_type])
+ - sizeof(zint);
p->head.block_used[dst_type]++;
}
assert(block_prev != -1);
}
for (i = 0; i<REC_BLOCK_TYPES; i++)
{
- if (!(p->data_BFile[i] = bf_open(bfs, p->data_fname[i],
- (int) (p->head.block_size[i]),
- rw)))
+ if (!(p->data_BFile[i] =
+ bf_open(bfs, p->data_fname[i],
+ CAST_ZINT_TO_INT(p->head.block_size[i]), rw)))
{
yaz_log(YLOG_FATAL|YLOG_ERRNO, "bf_open %s", p->data_fname[i]);
ret = ZEBRA_FAIL;
for (i = 0; i<REC_NO_INFO; i++)
{
- if (*out_offset + (int) rec->size[i] + 20 > *out_size)
+ if (*out_offset + CAST_ZINT_TO_INT(rec->size[i]) + 20 > *out_size)
{
int new_size = *out_offset + rec->size[i] + 65536;
char *np = (char *) xmalloc(new_size);
else
{
n->size[i] = rec->size[i];
- n->info[i] = (char *) xmalloc(rec->size[i]);
+ n->info[i] = (char *) xmalloc(rec->size[i]+1);
memcpy(n->info[i], rec->info[i], rec->size[i]);
+ n->info[i][rec->size[i]] = '\0';
}
return n;
}