diff options
author | Russell Belfer <rb@github.com> | 2013-04-12 12:44:51 -0700 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2013-04-22 16:50:51 +0200 |
commit | b12b72ea82776bbbd4296eeac1376055b0487edf (patch) | |
tree | 193ea7ff5f0a026c6157663cc9e181df3c3da364 /src/util.c | |
parent | badd85a61354ef7b62c5f8e53d740738e5ef1e57 (diff) | |
download | libgit2-b12b72ea82776bbbd4296eeac1376055b0487edf.tar.gz |
Add range checking around cache opts
Add a git_cache_set_max_object_size method that does more checking
around setting the max object size. Also add a git_cache_size to
read the number of objects currently in the cache. This makes it
easier to write tests.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/util.c b/src/util.c index 0b5fbdc5a..1ed5d5d16 100644 --- a/src/util.c +++ b/src/util.c @@ -95,14 +95,16 @@ int git_libgit2_opts(int key, ...) error = git_futils_dirs_set(error, va_arg(ap, const char *)); break; - case GIT_OPT_SET_CACHE_LIMIT: { + case GIT_OPT_SET_CACHE_LIMIT: + { git_otype type = (git_otype)va_arg(ap, int); - git_cache__max_object_size[type] = va_arg(ap, size_t); + size_t size = va_arg(ap, size_t); + error = git_cache_set_max_object_size(type, size); break; } case GIT_OPT_ENABLE_CACHING: - git_cache__enabled = va_arg(ap, int); + git_cache__enabled = (va_arg(ap, int) != 0); break; } |