FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/index.c
/*
 * Standard (de-)serialization functions
 */
Standard (de-)serialization functions
Standard ( de - ) serialization functions
svn_error_t *
svn_fs_fs__serialize_l2p_header(void **data,
                                apr_size_t *data_len,
                                void *in,
                                apr_pool_t *pool)
{
  l2p_header_t *header = in;
  svn_temp_serializer__context_t *context;
  svn_stringbuf_t *serialized;
  apr_size_t page_count = header->page_table_index[header->revision_count];
  apr_size_t page_table_size = page_count * sizeof(*header->page_table);
  apr_size_t index_size
    = (header->revision_count + 1) * sizeof(*header->page_table_index);
  apr_size_t data_size = sizeof(*header) + index_size + page_table_size;
  context = svn_temp_serializer__init(header,
                                      sizeof(*header),
                                      data_size + 32,
                                      pool);
  svn_temp_serializer__add_leaf(context,
                                (const void * const *)&header->page_table_index,
                                index_size);
  svn_temp_serializer__add_leaf(context,
                                (const void * const *)&header->page_table,
                                page_table_size);
  serialized = svn_temp_serializer__get(context);
  *data = serialized->data;
  *data_len = serialized->len;
  return SVN_NO_ERROR;
}
svn_error_t * svn_fs_fs__serialize_l2p_header ( void * * data , apr_size_t * data_len , void * in , apr_pool_t * pool ) { l2p_header_t * header = in ; svn_temp_serializer__context_t * context ; svn_stringbuf_t * serialized ; apr_size_t page_count = header -> page_table_index [ header -> revision_count ] ; apr_size_t page_table_size = page_count * sizeof ( * header -> page_table ) ; apr_size_t index_size = ( header -> revision_count + 1 ) * sizeof ( * header -> page_table_index ) ; apr_size_t data_size = sizeof ( * header ) + index_size + page_table_size ; context = svn_temp_serializer__init ( header , sizeof ( * header ) , data_size + 32 , pool ) ; svn_temp_serializer__add_leaf ( context , ( const void * const * ) & header -> page_table_index , index_size ) ; svn_temp_serializer__add_leaf ( context , ( const void * const * ) & header -> page_table , page_table_size ) ; serialized = svn_temp_serializer__get ( context ) ; * data = serialized -> data ; * data_len = serialized -> len ; return SVN_NO_ERROR ; }
Standard (de-)serialization functions
Standard ( de - ) serialization functions
/* serialize header and all its elements */ /* page table index array */ /* page table array */ /* return the serialized result */