-/* $Id: recindex.c,v 1.47 2006-03-26 14:17:01 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: recindex.c,v 1.51 2006-08-14 10:40:15 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
for more details.
You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
*/
#define RIDX_CHUNK 128
{
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;
}
return p;
}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+