X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Frecindex.c;h=95a4474932a92d65644da4c551cf780c6b61f53a;hb=c33ea56e3771c3b80ba66ef8fda3a09cad171ebb;hp=a888c85143e62486dd41321d9d3568f5e9275871;hpb=cdcde0c689ec4b66f1884dbd455284b7a35fb425;p=idzebra-moved-to-github.git diff --git a/index/recindex.c b/index/recindex.c index a888c85..95a4474 100644 --- a/index/recindex.c +++ b/index/recindex.c @@ -1,4 +1,4 @@ -/* $Id: recindex.c,v 1.49 2006-05-10 12:30:02 adam Exp $ +/* $Id: recindex.c,v 1.51 2006-08-14 10:40:15 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -15,9 +15,9 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 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 @@ -106,7 +106,7 @@ static int read_indx(Records p, SYSNO sysno, void *buf, int itemsize, { 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) @@ -127,7 +127,7 @@ static int read_indx(Records p, SYSNO sysno, void *buf, int 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) @@ -152,7 +152,7 @@ static ZEBRA_RES rec_release_blocks(Records p, SYSNO sysno) 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) @@ -259,7 +259,8 @@ static ZEBRA_RES rec_write_tmp_buf(Records p, int size, SYSNO *sysnos) 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); @@ -345,9 +346,9 @@ Records rec_open(BFiles bfs, int rw, int compression_method) } for (i = 0; idata_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; @@ -432,7 +433,7 @@ static void rec_cache_flush_block1(Records p, Record rec, Record last_rec, for (i = 0; isize[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);