- xfree (rset);
- xfree (rsfd);
- heap_close (ti);
- }
- else if (zi->reg->isam)
- {
- ISPT *ispt;
- int i;
- struct trunc_info *ti;
-
- ispt = (ISPT *) xmalloc (sizeof(*ispt) * (to-from));
-
- ti = heap_init (to-from, sizeof(struct it_key),
- key_compare_it);
- for (i = to-from; --i >= 0; )
- {
- ispt[i] = is_position (zi->reg->isam, isam_p[from+i]);
- if (is_readkey (ispt[i], ti->tmpbuf))
- heap_insert (ti, ti->tmpbuf, i);
- else
- is_pt_free (ispt[i]);
- }
- while (ti->heapnum)
- {
- int n = ti->indx[ti->ptr[1]];
-
- rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]);
- nn++;
- if (preserve_position)
- {
-/* section that preserve all keys */
- heap_delete (ti);
- if (is_readkey (ispt[n], ti->tmpbuf))
- heap_insert (ti, ti->tmpbuf, n);
- else
- is_pt_free (ispt[n]);
- }
- else
- {
-/* section that preserve all keys with unique sysnos */
- while (1)
- {
- if (!is_readkey (ispt[n], ti->tmpbuf))
- {
- heap_delete (ti);
- is_pt_free (ispt[n]);
- break;
- }
- if ((*ti->cmp)(ti->tmpbuf, ti->heap[ti->ptr[1]]) > 1)
- {
- heap_delete (ti);
- heap_insert (ti, ti->tmpbuf, n);
- break;
- }
- }
- }
- }
- heap_close (ti);
- xfree (ispt);