X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Ftrunc.c;h=887110b1ecb19c831123eb4c1f3dab3a9c25ad63;hb=93fc01961d210c8ada1d3147763da8f7293dcbfb;hp=c5113ac6715776d6c6c9655d9a2c093eeb778ca3;hpb=bceca936710690858ea162e7bc22de819f0e280f;p=idzebra-moved-to-github.git diff --git a/index/trunc.c b/index/trunc.c index c5113ac..887110b 100644 --- a/index/trunc.c +++ b/index/trunc.c @@ -4,7 +4,13 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: trunc.c,v $ - * Revision 1.13 1999-05-12 13:08:06 adam + * Revision 1.15 1999-07-20 13:59:18 adam + * Fixed bug that occurred when phrases had 0 hits. + * + * Revision 1.14 1999/05/26 07:49:13 adam + * C++ compilation. + * + * Revision 1.13 1999/05/12 13:08:06 adam * First version of ISAMS. * * Revision 1.12 1999/02/02 14:51:10 adam @@ -130,19 +136,19 @@ static struct trunc_info *heap_init (int size, int key_size, int (*cmp)(const void *p1, const void *p2)) { - struct trunc_info *ti = xmalloc (sizeof(*ti)); + struct trunc_info *ti = (struct trunc_info *) xmalloc (sizeof(*ti)); int i; ++size; ti->heapnum = 0; ti->keysize = key_size; ti->cmp = cmp; - ti->indx = xmalloc (size * sizeof(*ti->indx)); - ti->heap = xmalloc (size * sizeof(*ti->heap)); - ti->ptr = xmalloc (size * sizeof(*ti->ptr)); - ti->swapbuf = xmalloc (ti->keysize); - ti->tmpbuf = xmalloc (ti->keysize); - ti->buf = xmalloc (size * ti->keysize); + ti->indx = (int *) xmalloc (size * sizeof(*ti->indx)); + ti->heap = (char **) xmalloc (size * sizeof(*ti->heap)); + ti->ptr = (int *) xmalloc (size * sizeof(*ti->ptr)); + ti->swapbuf = (char *) xmalloc (ti->keysize); + ti->tmpbuf = (char *) xmalloc (ti->keysize); + ti->buf = (char *) xmalloc (size * ti->keysize); for (i = size; --i >= 0; ) { ti->ptr[i] = i; @@ -186,8 +192,8 @@ static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length, int rscur = 0; int rsmax = (to-from)/i_add + 1; - rset = xmalloc (sizeof(*rset) * rsmax); - rsfd = xmalloc (sizeof(*rsfd) * rsmax); + rset = (RSET *) xmalloc (sizeof(*rset) * rsmax); + rsfd = (RSFD *) xmalloc (sizeof(*rsfd) * rsmax); for (i = from; i < to; i += i_add) { @@ -244,7 +250,7 @@ static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length, int i; struct trunc_info *ti; - ispt = xmalloc (sizeof(*ispt) * (to-from)); + ispt = (ISPT *) xmalloc (sizeof(*ispt) * (to-from)); ti = heap_init (to-from, sizeof(struct it_key), key_compare_it); @@ -296,7 +302,7 @@ static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length, int i; struct trunc_info *ti; - ispt = xmalloc (sizeof(*ispt) * (to-from)); + ispt = (ISAMC_PP *) xmalloc (sizeof(*ispt) * (to-from)); ti = heap_init (to-from, sizeof(struct it_key), key_compare_it); @@ -348,7 +354,7 @@ static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length, int i; struct trunc_info *ti; - ispt = xmalloc (sizeof(*ispt) * (to-from)); + ispt = (ISAMS_PP *) xmalloc (sizeof(*ispt) * (to-from)); ti = heap_init (to-from, sizeof(struct it_key), key_compare_it); @@ -424,11 +430,15 @@ RSET rset_trunc (ZebraHandle zi, ISAM_P *isam_p, int no, const char *term, int length, const char *flags) { logf (LOG_DEBUG, "rset_trunc no=%d", no); + if (no < 1) + { + rset_null_parms parms; + parms.rset_term = rset_term_create (term, length, flags); + return rset_create (rset_kind_null, &parms); + } if (zi->isam) { - if (no < 1) - return rset_create (rset_kind_null, NULL); - else if (no == 1) + if (no == 1) { rset_isam_parms parms; @@ -441,9 +451,7 @@ RSET rset_trunc (ZebraHandle zi, ISAM_P *isam_p, int no, } else if (zi->isamc) { - if (no < 1) - return rset_create (rset_kind_null, NULL); - else if (no == 1) + if (no == 1) { rset_isamc_parms parms; @@ -471,9 +479,7 @@ RSET rset_trunc (ZebraHandle zi, ISAM_P *isam_p, int no, } else if (zi->isams) { - if (no < 1) - return rset_create (rset_kind_null, NULL); - else if (no == 1) + if (no == 1) { rset_isams_parms parms;