X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Frecindex.c;h=69237dafefdc6b31b27b592902552720d805bac7;hb=1bf3c420dad254b9b0275f28541772e28197e19f;hp=a888c85143e62486dd41321d9d3568f5e9275871;hpb=cdcde0c689ec4b66f1884dbd455284b7a35fb425;p=idzebra-moved-to-github.git diff --git a/index/recindex.c b/index/recindex.c index a888c85..69237da 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.52 2006-09-15 10:45:13 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); @@ -590,7 +591,7 @@ static ZEBRA_RES rec_cache_flush(Records p, int saveCount) for (i = 0; icache_cur - saveCount; i++) { struct record_cache_entry *e = p->record_cache + i; - rec_rm(&e->rec); + rec_free(&e->rec); } /* i still being used ... */ for (j = 0; jhead.no_records)--; if ((recp = rec_cache_lookup(p, (*recpp)->sysno, recordFlagDelete))) { - rec_rm(recp); + rec_free(recp); *recp = *recpp; } else { ret = rec_cache_insert(p, *recpp, recordFlagDelete); - rec_rm(recpp); + rec_free(recpp); } zebra_mutex_unlock(&p->mutex); *recpp = NULL; @@ -914,20 +915,20 @@ ZEBRA_RES rec_put(Records p, Record *recpp) zebra_mutex_lock(&p->mutex); if ((recp = rec_cache_lookup(p, (*recpp)->sysno, recordFlagWrite))) { - rec_rm(recp); + rec_free(recp); *recp = *recpp; } else { ret = rec_cache_insert(p, *recpp, recordFlagWrite); - rec_rm(recpp); + rec_free(recpp); } zebra_mutex_unlock(&p->mutex); *recpp = NULL; return ret; } -void rec_rm(Record *recpp) +void rec_free(Record *recpp) { int i;