FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/index.c
/* Calculate the FNV1 checksum over the offset range in REV_FILE, covered by
 * ENTRY.  Store the result in ENTRY->FNV1_CHECKSUM.  Use SCRATCH_POOL for
 * temporary allocations. */
Calculate the FNV1 checksum over the offset range in REV_FILE, covered by
ENTRY.  Store the result in ENTRY->FNV1_CHECKSUM.  Use SCRATCH_POOL for
temporary allocations.
Calculate the FNV1 checksum over the offset range in REV_FILE covered by ENTRY . Store the result in ENTRY - > FNV1_CHECKSUM . Use SCRATCH_POOL for temporary allocations .
static svn_error_t *
calc_fnv1(svn_fs_fs__p2l_entry_t *entry,
          svn_fs_fs__revision_file_t *rev_file,
          apr_pool_t *scratch_pool)
{
  unsigned char buffer[4096];
  svn_checksum_t *checksum;
  svn_checksum_ctx_t *context
    = svn_checksum_ctx_create(svn_checksum_fnv1a_32x4, scratch_pool);
  apr_off_t size = entry->size;
  if (entry->type == SVN_FS_FS__ITEM_TYPE_UNUSED)
    {
      entry->fnv1_checksum = 0;
      return SVN_NO_ERROR;
    }
  SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &entry->offset,
                           scratch_pool));
  while (size > 0)
    {
      apr_size_t to_read = size > sizeof(buffer)
                         ? sizeof(buffer)
                         : (apr_size_t)size;
      SVN_ERR(svn_io_file_read_full2(rev_file->file, buffer, to_read, NULL,
                                     NULL, scratch_pool));
      SVN_ERR(svn_checksum_update(context, buffer, to_read));
      size -= to_read;
    }
  SVN_ERR(svn_checksum_final(&checksum, context, scratch_pool));
  entry->fnv1_checksum = ntohl(*(const apr_uint32_t *)checksum->digest);
  return SVN_NO_ERROR;
}
static svn_error_t * calc_fnv1 ( svn_fs_fs__p2l_entry_t * entry , svn_fs_fs__revision_file_t * rev_file , apr_pool_t * scratch_pool ) { unsigned char buffer [ 4096 ] ; svn_checksum_t * checksum ; svn_checksum_ctx_t * context = svn_checksum_ctx_create ( svn_checksum_fnv1a_32x4 , scratch_pool ) ; apr_off_t size = entry -> size ; if ( entry -> type == SVN_FS_FS__ITEM_TYPE_UNUSED ) { entry -> fnv1_checksum = 0 ; return SVN_NO_ERROR ; } SVN_ERR ( svn_io_file_seek ( rev_file -> file , APR_SET , & entry -> offset , scratch_pool ) ) ; while ( size > 0 ) { apr_size_t to_read = size > sizeof ( buffer ) ? sizeof ( buffer ) : ( apr_size_t ) size ; SVN_ERR ( svn_io_file_read_full2 ( rev_file -> file , buffer , to_read , NULL , NULL , scratch_pool ) ) ; SVN_ERR ( svn_checksum_update ( context , buffer , to_read ) ) ; size -= to_read ; } SVN_ERR ( svn_checksum_final ( & checksum , context , scratch_pool ) ) ; entry -> fnv1_checksum = ntohl ( * ( const apr_uint32_t * ) checksum -> digest ) ; return SVN_NO_ERROR ; }
Calculate the FNV1 checksum over the offset range in REV_FILE, covered by
 ENTRY.
Calculate the FNV1 checksum over the offset range in REV_FILE covered by ENTRY .
/* Special rules apply to unused sections / items.  The data must be a
   * sequence of NUL bytes (not checked here) and the checksum is fixed to 0.
   */ /* Read the block and feed it to the checksum calculator. */ /* Store final checksum in ENTRY. */