Skip to content

Commit f4b473f

Browse files
authored
Merge pull request libgit2#5746 from libgit2/ethomson/configmapcache
repository: use intptr_t's in the config map cache
2 parents 70ed308 + 1b70868 commit f4b473f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/config_cache.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,21 @@ int git_config__configmap_lookup(int *out, git_config *config, git_configmap_ite
111111

112112
int git_repository__configmap_lookup(int *out, git_repository *repo, git_configmap_item item)
113113
{
114-
*out = (int)(intptr_t)git_atomic_load(repo->configmap_cache[(int)item]);
114+
intptr_t value = (intptr_t)git_atomic_load(repo->configmap_cache[(int)item]);
115115

116-
if (*out == GIT_CONFIGMAP_NOT_CACHED) {
117-
int error;
118-
int oldval = GIT_CONFIGMAP_NOT_CACHED;
116+
*out = (int)value;
117+
118+
if (value == GIT_CONFIGMAP_NOT_CACHED) {
119119
git_config *config;
120+
intptr_t oldval = value;
121+
int error;
120122

121123
if ((error = git_repository_config__weakptr(&config, repo)) < 0 ||
122124
(error = git_config__configmap_lookup(out, config, item)) < 0)
123125
return error;
124126

125-
git_atomic_compare_and_swap(&repo->configmap_cache[(int)item], &oldval, out);
127+
value = *out;
128+
git_atomic_compare_and_swap(&repo->configmap_cache[(int)item], (void *)oldval, (void *)value);
126129
}
127130

128131
return 0;

src/repository.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ struct git_repository {
154154

155155
git_atomic32 attr_session_key;
156156

157-
git_configmap_value configmap_cache[GIT_CONFIGMAP_CACHE_MAX];
157+
intptr_t configmap_cache[GIT_CONFIGMAP_CACHE_MAX];
158158
git_strmap *submodule_cache;
159159
};
160160

0 commit comments

Comments
 (0)