summaryrefslogtreecommitdiff
path: root/src/strmap.h
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-05-05 14:22:06 -0700
committerVicent Martí <tanoku@gmail.com>2012-05-05 14:22:06 -0700
commit4ef14af93517b3842bc0dfa24147cf10dd029582 (patch)
tree88f90fa8c9d903f072a2b1c647c51a9899e520c7 /src/strmap.h
parentf95e8cc07c85034f737872455fce2895186be19d (diff)
parent282283acc65bab9de231a2b3dc489eb171d5f1cf (diff)
downloadlibgit2-development-merge.tar.gz
Merge pull request #664 from arrbee/attrs-from-indexdevelopment-merge
Support git attrs from index (and bare repo)
Diffstat (limited to 'src/strmap.h')
-rw-r--r--src/strmap.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/strmap.h b/src/strmap.h
index 55fbd7c6e..da5ca0dba 100644
--- a/src/strmap.h
+++ b/src/strmap.h
@@ -36,18 +36,28 @@ typedef khash_t(str) git_strmap;
#define git_strmap_set_value_at(h, idx, v) kh_val(h, idx) = v
#define git_strmap_delete_at(h, idx) kh_del(str, h, idx)
-#define git_strmap_insert(h, key, val, err) do { \
- khiter_t __pos = kh_put(str, h, key, &err); \
- if (err >= 0) kh_val(h, __pos) = val; \
- } while (0)
-
-#define git_strmap_insert2(h, key, val, old, err) do { \
- khiter_t __pos = kh_put(str, h, key, &err); \
- if (err >= 0) { \
- old = (err == 0) ? kh_val(h, __pos) : NULL; \
+#define git_strmap_insert(h, key, val, rval) do { \
+ khiter_t __pos = kh_put(str, h, key, &rval); \
+ if (rval >= 0) { \
+ if (rval == 0) kh_key(h, __pos) = key; \
kh_val(h, __pos) = val; \
} } while (0)
+#define git_strmap_insert2(h, key, val, oldv, rval) do { \
+ khiter_t __pos = kh_put(str, h, key, &rval); \
+ if (rval >= 0) { \
+ if (rval == 0) { \
+ oldv = kh_val(h, __pos); \
+ kh_key(h, __pos) = key; \
+ } else { oldv = NULL; } \
+ kh_val(h, __pos) = val; \
+ } } while (0)
+
+#define git_strmap_delete(h, key) do { \
+ khiter_t __pos = git_strmap_lookup_index(h, key); \
+ if (git_strmap_valid_index(h, __pos)) \
+ git_strmap_delete_at(h, __pos); } while (0)
+
#define git_strmap_foreach kh_foreach
#define git_strmap_foreach_value kh_foreach_value