FreeBSD/contrib/subversion/subversion/libsvn_delta/text_delta.c
/* This is the write handler for a target-push delta stream.  It reads
 * source data, buffers target data, and fires off delta windows when
 * the target data buffer is full. */
This is the write handler for a target-push delta stream.  It reads
source data, buffers target data, and fires off delta windows when
the target data buffer is full.
This is the write handler for a target - push delta stream . It reads source data buffers target data and fires off delta windows when the target data buffer is full .
static svn_error_t *
tpush_write_handler(void *baton, const char *data, apr_size_t *len)
{
  struct tpush_baton *tb = baton;
  apr_size_t chunk_len, data_len = *len;
  apr_pool_t *pool = svn_pool_create(tb->pool);
  svn_txdelta_window_t *window;
  while (data_len > 0)
    {
      svn_pool_clear(pool);
      if (tb->source_len == 0 && !tb->source_done)
        {
          tb->source_len = SVN_DELTA_WINDOW_SIZE;
          SVN_ERR(svn_stream_read_full(tb->source, tb->buf, &tb->source_len));
          if (tb->source_len < SVN_DELTA_WINDOW_SIZE)
            tb->source_done = TRUE;
        }
      chunk_len = SVN_DELTA_WINDOW_SIZE - tb->target_len;
      if (chunk_len > data_len)
        chunk_len = data_len;
      memcpy(tb->buf + tb->source_len + tb->target_len, data, chunk_len);
      data += chunk_len;
      data_len -= chunk_len;
      tb->target_len += chunk_len;
      if (tb->target_len == SVN_DELTA_WINDOW_SIZE)
        {
          window = compute_window(tb->buf, tb->source_len, tb->target_len,
                                  tb->source_offset, pool);
          SVN_ERR(tb->wh(window, tb->whb));
          tb->source_offset += tb->source_len;
          tb->source_len = 0;
          tb->target_len = 0;
        }
    }
  svn_pool_destroy(pool);
  return SVN_NO_ERROR;
}
static svn_error_t * tpush_write_handler ( void * baton , const char * data , apr_size_t * len ) { struct tpush_baton * tb = baton ; apr_size_t chunk_len , data_len = * len ; apr_pool_t * pool = svn_pool_create ( tb -> pool ) ; svn_txdelta_window_t * window ; while ( data_len > 0 ) { svn_pool_clear ( pool ) ; if ( tb -> source_len == 0 && ! tb -> source_done ) { tb -> source_len = SVN_DELTA_WINDOW_SIZE ; SVN_ERR ( svn_stream_read_full ( tb -> source , tb -> buf , & tb -> source_len ) ) ; if ( tb -> source_len < SVN_DELTA_WINDOW_SIZE ) tb -> source_done = TRUE ; } chunk_len = SVN_DELTA_WINDOW_SIZE - tb -> target_len ; if ( chunk_len > data_len ) chunk_len = data_len ; memcpy ( tb -> buf + tb -> source_len + tb -> target_len , data , chunk_len ) ; data += chunk_len ; data_len -= chunk_len ; tb -> target_len += chunk_len ; if ( tb -> target_len == SVN_DELTA_WINDOW_SIZE ) { window = compute_window ( tb -> buf , tb -> source_len , tb -> target_len , tb -> source_offset , pool ) ; SVN_ERR ( tb -> wh ( window , tb -> whb ) ) ; tb -> source_offset += tb -> source_len ; tb -> source_len = 0 ; tb -> target_len = 0 ; } } svn_pool_destroy ( pool ) ; return SVN_NO_ERROR ; }
This is the write handler for a target-push delta stream.
This is the write handler for a target - push delta stream .
/* Make sure we're all full up on source data, if possible. */ /* Copy in the target data, up to SVN_DELTA_WINDOW_SIZE. */ /* If we're full of target data, compute and fire off a window. */