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:
authorNico von Geyso <Nico.Geyso@FU-Berlin.de>2013-03-17 23:39:01 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2013-08-08 13:07:03 +0400
commit6385fc5ff5d669d3ec99d89f19c5860cf53011ba (patch)
tree56dfda0bba992c09c7d336600f1844b95d0ae863 /src/strmap.c
parentc7d4904c47d493073b8f816d2b17dcf68eefe26d (diff)
added new type and several functions to git_strmap
This step is needed to easily add iterators to git_config_backend As well use these new git_strmap functions to implement foreach * git_strmap_iter * git_strmap_has_data(...) * git_strmap_begin(...) * git_strmap_end(...) * git_strmap_next(...)
Diffstat (limited to 'src/strmap.c')
-rw-r--r--src/strmap.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/strmap.c b/src/strmap.c
new file mode 100644
index 000000000..1b07359d1
--- /dev/null
+++ b/src/strmap.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "strmap.h"
+
+int git_strmap_next(
+ const char **key,
+ void **data,
+ git_strmap_iter* iter,
+ git_strmap *map)
+{
+ if (!map)
+ return GIT_ERROR;
+
+ while (*iter != git_strmap_end(map)) {
+ if (!(git_strmap_has_data(map, *iter))) {
+ ++(*iter);
+ continue;
+ }
+
+ *key = git_strmap_key(map, *iter);
+ *data = git_strmap_value_at(map, *iter);
+
+ ++(*iter);
+
+ return GIT_OK;
+ }
+
+ return GIT_ITEROVER;
+}