Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-04-25 21:36:01 +0400
committerRussell Belfer <rb@github.com>2012-04-25 22:18:08 +0400
commit01fed0a8f9b80e80c8f76cde29fc0d66cb77fff7 (patch)
tree817dbac7a66529c1a25d26cc256b819564b6cb03 /src/attr.h
parentada488bfe720d0df8187b5b58e326a13b7bdc678 (diff)
Convert hashtable usage over to khash
This updates khash.h with some extra features (like error checking on allocations, ability to use wrapped malloc, foreach calls, etc), creates two high-level wrappers around khash: `git_khash_str` and `git_khash_oid` for string-to-void-ptr and oid-to-void-ptr tables, then converts all of the old usage of `git_hashtable` over to use these new hashtables. For `git_khash_str`, I've tried to create a set of macros that yield an API not too unlike the old `git_hashtable` API. Since the oid hashtable is only used in one file, I haven't bother to set up all those macros and just use the khash APIs directly for now.
Diffstat (limited to 'src/attr.h')
-rw-r--r--src/attr.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/attr.h b/src/attr.h
index 825cbfe4e..75e98607f 100644
--- a/src/attr.h
+++ b/src/attr.h
@@ -8,6 +8,7 @@
#define INCLUDE_attr_h__
#include "attr_file.h"
+#include "khash_str.h"
#define GIT_ATTR_CONFIG "core.attributesfile"
#define GIT_IGNORE_CONFIG "core.excludesfile"
@@ -15,8 +16,8 @@
typedef struct {
int initialized;
git_pool pool;
- git_hashtable *files; /* hash path to git_attr_file of rules */
- git_hashtable *macros; /* hash name to vector<git_attr_assignment> */
+ git_khash_str *files; /* hash path to git_attr_file of rules */
+ git_khash_str *macros; /* hash name to vector<git_attr_assignment> */
const char *cfg_attr_file; /* cached value of core.attributesfile */
const char *cfg_excl_file; /* cached value of core.excludesfile */
} git_attr_cache;
@@ -26,6 +27,9 @@ extern int git_attr_cache__init(git_repository *repo);
extern int git_attr_cache__insert_macro(
git_repository *repo, git_attr_rule *macro);
+extern git_attr_rule *git_attr_cache__lookup_macro(
+ git_repository *repo, const char *name);
+
extern int git_attr_cache__lookup_or_create_file(
git_repository *repo,
const char *key,