FreeBSD/contrib/subversion/subversion/libsvn_fs_x/revprops.c
/* Writes the a pack file to FILE_STREAM.  It copies the serialized data
 * from REVPROPS for the indexes [START,END) except for index CHANGED_INDEX.
 *
 * The data for the latter is taken from NEW_SERIALIZED.  Note, that
 * CHANGED_INDEX may be outside the [START,END) range, i.e. no new data is
 * taken in that case but only a subset of the old data will be copied.
 *
 * NEW_TOTAL_SIZE is a hint for pre-allocating buffers of appropriate size.
 * SCRATCH_POOL is used for temporary allocations.
 */
Writes the a pack file to FILE_STREAM.  It copies the serialized data
from REVPROPS for the indexes [START,END) except for index CHANGED_INDEX.

The data for the latter is taken from NEW_SERIALIZED.  Note, that
CHANGED_INDEX may be outside the [START,END) range, i.e. no new data is
taken in that case but only a subset of the old data will be copied.

NEW_TOTAL_SIZE is a hint for pre-allocating buffers of appropriate size.
SCRATCH_POOL is used for temporary allocations.
Writes the a pack file to FILE_STREAM . It copies the serialized data from REVPROPS for the indexes [ START END ) except for index CHANGED_INDEX . The data for the latter is taken from NEW_SERIALIZED . Note that CHANGED_INDEX may be outside the [ START END ) range i . e . no new data is taken in that case but only a subset of the old data will be copied . NEW_TOTAL_SIZE is a hint for pre - allocating buffers of appropriate size . SCRATCH_POOL is used for temporary allocations .
static svn_error_t *
repack_revprops(svn_fs_t *fs,
                packed_revprops_t *revprops,
                int start,
                int end,
                int changed_index,
                svn_stringbuf_t *new_serialized,
                apr_off_t new_total_size,
                svn_stream_t *file_stream,
                apr_pool_t *scratch_pool)
{
  svn_fs_x__data_t *ffd = fs->fsap_data;
  svn_stream_t *stream;
  int i;
  svn_stringbuf_t *uncompressed
    = svn_stringbuf_create_ensure((apr_size_t)new_total_size, scratch_pool);
  svn_stringbuf_t *compressed
    = svn_stringbuf_create_empty(scratch_pool);
  stream = svn_stream_from_stringbuf(uncompressed, scratch_pool);
  SVN_ERR(serialize_revprops_header(stream, revprops->start_revision + start,
                                    revprops->sizes, start, end,
                                    scratch_pool));
  for (i = start; i < end; ++i)
    if (i == changed_index)
      {
        SVN_ERR(svn_stream_write(stream,
                                 new_serialized->data,
                                 &new_serialized->len));
      }
    else
      {
        apr_size_t size
            = (apr_size_t)APR_ARRAY_IDX(revprops->sizes, i, apr_off_t);
        apr_size_t offset
            = (apr_size_t)APR_ARRAY_IDX(revprops->offsets, i, apr_off_t);
        SVN_ERR(svn_stream_write(stream,
                                 revprops->packed_revprops->data + offset,
                                 &size));
      }
  SVN_ERR(svn_stream_close(stream));
  SVN_ERR(svn__compress(uncompressed,
                        compressed,
                        ffd->compress_packed_revprops
                          ? SVN_DELTA_COMPRESSION_LEVEL_DEFAULT
                          : SVN_DELTA_COMPRESSION_LEVEL_NONE));
  SVN_ERR(svn_stream_write(file_stream, compressed->data, &compressed->len));
  SVN_ERR(svn_stream_close(file_stream));
  return SVN_NO_ERROR;
}
static svn_error_t * repack_revprops ( svn_fs_t * fs , packed_revprops_t * revprops , int start , int end , int changed_index , svn_stringbuf_t * new_serialized , apr_off_t new_total_size , svn_stream_t * file_stream , apr_pool_t * scratch_pool ) { svn_fs_x__data_t * ffd = fs -> fsap_data ; svn_stream_t * stream ; int i ; svn_stringbuf_t * uncompressed = svn_stringbuf_create_ensure ( ( apr_size_t ) new_total_size , scratch_pool ) ; svn_stringbuf_t * compressed = svn_stringbuf_create_empty ( scratch_pool ) ; stream = svn_stream_from_stringbuf ( uncompressed , scratch_pool ) ; SVN_ERR ( serialize_revprops_header ( stream , revprops -> start_revision + start , revprops -> sizes , start , end , scratch_pool ) ) ; for ( i = start ; i < end ; ++ i ) if ( i == changed_index ) { SVN_ERR ( svn_stream_write ( stream , new_serialized -> data , & new_serialized -> len ) ) ; } else { apr_size_t size = ( apr_size_t ) APR_ARRAY_IDX ( revprops -> sizes , i , apr_off_t ) ; apr_size_t offset = ( apr_size_t ) APR_ARRAY_IDX ( revprops -> offsets , i , apr_off_t ) ; SVN_ERR ( svn_stream_write ( stream , revprops -> packed_revprops -> data + offset , & size ) ) ; } SVN_ERR ( svn_stream_close ( stream ) ) ; SVN_ERR ( svn__compress ( uncompressed , compressed , ffd -> compress_packed_revprops ? SVN_DELTA_COMPRESSION_LEVEL_DEFAULT : SVN_DELTA_COMPRESSION_LEVEL_NONE ) ) ; SVN_ERR ( svn_stream_write ( file_stream , compressed -> data , & compressed -> len ) ) ; SVN_ERR ( svn_stream_close ( file_stream ) ) ; return SVN_NO_ERROR ; }
Writes the a pack file to FILE_STREAM.
Writes the a pack file to FILE_STREAM .
/* create data empty buffers and the stream object */ /* write the header*/ /* append the serialized revprops */ /* flush the stream buffer (if any) to our underlying data buffer */ /* compress / store the data */ /* finally, write the content to the target stream and close it */