- memcpy (r_item, i_item, i_item_ptr - i_item);
- dirty_ptr[r_ptri-1] = 1;
- /* move i */
- i_item_ptr = i_item;
- i_more = (*data->read_item)(data->clientData, &i_item_ptr,
- &i_mode);
- }
- if (r_item) /* insert resulting item? */
- {
- char *r_out_ptr = r_buf + r_offset;
- int new_offset;
- int border;
-
- /* border set to initial fill or block size depending on
- whether we are creating a new one or updating and old
- */
- if (block_ptr[r_ptri-1])
- border = r_ptr[r_ptri-1] + is->method->filecat[cat].bsize
- -ISAMC_BLOCK_OFFSET;
- else
- border = r_ptr[r_ptri-1] + is->method->filecat[cat].ifill
- -ISAMC_BLOCK_OFFSET;
-
- (*is->method->code_item)(ISAMC_ENCODE, r_clientData,
- &r_out_ptr, &r_item);
- new_offset = r_out_ptr - r_buf;
-
- if (border >= r_offset && border < new_offset)
- {
- /* Initial fill of current block category reached...
- Save offset in r_ptr
- */
- r_ptr[r_ptri++] = r_offset;
- if (cat == is->max_cat)
- {
- /* We are dealing with block of max size. Block(s)
- will be flushed. Note: the block(s) are surely not
- the last one(s).
- */
- if (is->method->debug > 1)
- logf (LOG_LOG, "isc: flush %d sections", r_ptri-1);
- isc_flush_blocks (is, r_ptr, r_ptri, r_buf,
- &nextpos, &firstpos, cat, 0);
- r_ptri = 0;
- r_ptr[r_ptri++] = 0;
- memcpy (r_buf, r_buf + r_offset, new_offset - r_offset);
- new_offset = (new_offset - r_offset);
- }
- }
- r_offset = new_offset;
- if (cat < is->max_cat &&
- r_ptri>is->method->filecat[cat].mblocks)
- {
- /* Max number blocks in current category reached ->
- must switch to next category (with larger block size)
- */
- int j = 1;
- cat++;
- /* r_ptr[0] = r_ptr[0] = 0 true anyway.. */
- /* AD: Any old blocks should be deleted */
- for (i = 2; i < r_ptri; i++)
- {
- border = is->method->filecat[cat].ifill -
- ISAMC_BLOCK_OFFSET + r_ptr[j-1];
- if (r_ptr[i] > border && r_ptr[i-1] <= border)
- r_ptr[j++] = r_ptr[i-1];
- }
- r_ptri = j;
- }
- }