FreeBSD/contrib/subversion/subversion/libsvn_repos/config_pool.c
/* Store a URL@REVISION to CHECKSUM, REPOS_ROOT in CONFIG_POOL.
 */
Store a URL@REVISION to CHECKSUM, REPOS_ROOT in CONFIG_POOL.
Store a URL@REVISION to CHECKSUM REPOS_ROOT in CONFIG_POOL .
static svn_error_t *
add_checksum(svn_repos__config_pool_t *config_pool,
             const char *url,
             const char *repos_root,
             svn_revnum_t revision,
             svn_checksum_t *checksum)
{
  apr_size_t path_len = strlen(url);
  apr_pool_t *pool = config_pool->in_repo_hash_pool;
  in_repo_config_t *config = apr_hash_get(config_pool->in_repo_configs,
                                          url, path_len);
  if (config)
    {
      memcpy((void *)config->key->digest, checksum->digest,
             svn_checksum_size(checksum));
      config->revision = revision;
      if (strcmp(config->repo_root, repos_root))
        config->repo_root = apr_pstrdup(pool, repos_root);
    }
  else
    {
      if (2 * svn_object_pool__count(config_pool->object_pool)
          < apr_hash_count(config_pool->in_repo_configs))
        {
          svn_pool_clear(pool);
          config_pool->in_repo_configs = svn_hash__make(pool);
        }
      config = apr_pcalloc(pool, sizeof(*config));
      config->key = svn_checksum_dup(checksum, pool);
      config->url = apr_pstrmemdup(pool, url, path_len);
      config->repo_root = apr_pstrdup(pool, repos_root);
      config->revision = revision;
      apr_hash_set(config_pool->in_repo_configs, url, path_len, config);
    }
  return SVN_NO_ERROR;
}
static svn_error_t * add_checksum ( svn_repos__config_pool_t * config_pool , const char * url , const char * repos_root , svn_revnum_t revision , svn_checksum_t * checksum ) { apr_size_t path_len = strlen ( url ) ; apr_pool_t * pool = config_pool -> in_repo_hash_pool ; in_repo_config_t * config = apr_hash_get ( config_pool -> in_repo_configs , url , path_len ) ; if ( config ) { memcpy ( ( void * ) config -> key -> digest , checksum -> digest , svn_checksum_size ( checksum ) ) ; config -> revision = revision ; if ( strcmp ( config -> repo_root , repos_root ) ) config -> repo_root = apr_pstrdup ( pool , repos_root ) ; } else { if ( 2 * svn_object_pool__count ( config_pool -> object_pool ) < apr_hash_count ( config_pool -> in_repo_configs ) ) { svn_pool_clear ( pool ) ; config_pool -> in_repo_configs = svn_hash__make ( pool ) ; } config = apr_pcalloc ( pool , sizeof ( * config ) ) ; config -> key = svn_checksum_dup ( checksum , pool ) ; config -> url = apr_pstrmemdup ( pool , url , path_len ) ; config -> repo_root = apr_pstrdup ( pool , repos_root ) ; config -> revision = revision ; apr_hash_set ( config_pool -> in_repo_configs , url , path_len , config ) ; } return SVN_NO_ERROR ; }
Store a URL@REVISION to CHECKSUM, REPOS_ROOT in CONFIG_POOL.
Store a URL@REVISION to CHECKSUM REPOS_ROOT in CONFIG_POOL .
/* update the existing entry */ /* duplicate the string only if necessary */ /* insert a new entry.
       * Limit memory consumption by cyclically clearing pool and hash. */ /* construct the new entry */ /* add to index */