FreeBSD/contrib/subversion/subversion/libsvn_subr/packed_data.c
/* Empty the unprocessed integer buffer in STREAM by either pushing the
 * data to the sub-streams or writing to the packed data (in case there
 * are no sub-streams).
 */
Empty the unprocessed integer buffer in STREAM by either pushing the
data to the sub-streams or writing to the packed data (in case there
are no sub-streams).
Empty the unprocessed integer buffer in STREAM by either pushing the data to the sub - streams or writing to the packed data ( in case there are no sub - streams ) .
static void
svn_packed__data_flush_buffer(svn_packed__int_stream_t *stream)
{
  packed_int_private_t *private_data = stream->private_data;
  apr_size_t i;
  if (private_data->current_substream)
    for (i = 0; i < stream->buffer_used; ++i)
      {
        packed_int_private_t *current_private_data
          = private_data->current_substream->private_data;
        svn_packed__add_uint(private_data->current_substream,
                             stream->buffer[i]);
        private_data->current_substream = current_private_data->next;
      }
  else
    {
      unsigned char local_buffer[10 * SVN__PACKED_DATA_BUFFER_SIZE];
      unsigned char *p = local_buffer;
      if (private_data->diff)
        {
          apr_uint64_t last_value = private_data->last_value;
          for (i = 0; i < stream->buffer_used; ++i)
            {
              apr_uint64_t temp = stream->buffer[i];
              stream->buffer[i] = remap_uint(temp - last_value);
              last_value = temp;
            }
          private_data->last_value = last_value;
        }
      if (!private_data->diff && private_data->is_signed)
        for (i = 0; i < stream->buffer_used; ++i)
          stream->buffer[i] = remap_uint(stream->buffer[i]);
      if (private_data->packed == NULL)
        private_data->packed
          = svn_stringbuf_create_ensure(256, private_data->pool);
      for (i = 0; i < stream->buffer_used; ++i)
        p = write_packed_uint_body(p, stream->buffer[i]);
      svn_stringbuf_appendbytes(private_data->packed,
                                (char *)local_buffer,
                                p - local_buffer);
    }
  private_data->item_count += stream->buffer_used;
  stream->buffer_used = 0;
}
static void svn_packed__data_flush_buffer ( svn_packed__int_stream_t * stream ) { packed_int_private_t * private_data = stream -> private_data ; apr_size_t i ; if ( private_data -> current_substream ) for ( i = 0 ; i < stream -> buffer_used ; ++ i ) { packed_int_private_t * current_private_data = private_data -> current_substream -> private_data ; svn_packed__add_uint ( private_data -> current_substream , stream -> buffer [ i ] ) ; private_data -> current_substream = current_private_data -> next ; } else { unsigned char local_buffer [ 10 * SVN__PACKED_DATA_BUFFER_SIZE ] ; unsigned char * p = local_buffer ; if ( private_data -> diff ) { apr_uint64_t last_value = private_data -> last_value ; for ( i = 0 ; i < stream -> buffer_used ; ++ i ) { apr_uint64_t temp = stream -> buffer [ i ] ; stream -> buffer [ i ] = remap_uint ( temp - last_value ) ; last_value = temp ; } private_data -> last_value = last_value ; } if ( ! private_data -> diff && private_data -> is_signed ) for ( i = 0 ; i < stream -> buffer_used ; ++ i ) stream -> buffer [ i ] = remap_uint ( stream -> buffer [ i ] ) ; if ( private_data -> packed == NULL ) private_data -> packed = svn_stringbuf_create_ensure ( 256 , private_data -> pool ) ; for ( i = 0 ; i < stream -> buffer_used ; ++ i ) p = write_packed_uint_body ( p , stream -> buffer [ i ] ) ; svn_stringbuf_appendbytes ( private_data -> packed , ( char * ) local_buffer , p - local_buffer ) ; } private_data -> item_count += stream -> buffer_used ; stream -> buffer_used = 0 ; }
Empty the unprocessed integer buffer in STREAM by either pushing the
 data to the sub-streams or writing to the packed data (in case there
 are no sub-streams).
Empty the unprocessed integer buffer in STREAM by either pushing the data to the sub - streams or writing to the packed data ( in case there are no sub - streams ) .
/* if we have sub-streams, push the data down to them */ /* pack the numbers into our local PACKED buffer */ /* temporary buffer, max 10 bytes required per 7b/8b encoded number */ /* if configured, deltify numbers before packing them.
         Since delta may be negative, always use the 'signed' encoding. */ /* if configured and not already done by the deltification above,
         transform to 'signed' encoding.  Store the sign in the LSB and
         the absolute value (-1 for negative values) in the remaining
         63 bits. */ /* auto-create packed data buffer.  Give it some reasonable initial
         size - just enough for a few tens of values. */ /* encode numbers into our temp buffer. */ /* append them to the final packed data */ /* maintain counters */