]> git.proxmox.com Git - libgit2.git/blob - src/offmap.h
Add BD on ca-certificates
[libgit2.git] / src / offmap.h
1 /*
2 * Copyright (C) 2012 the libgit2 contributors
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7 #ifndef INCLUDE_offmap_h__
8 #define INCLUDE_offmap_h__
9
10 #include "common.h"
11
12 #include "git2/types.h"
13
14 typedef struct kh_off_s git_offmap;
15
16 git_offmap *git_offmap_alloc(void);
17 void git_offmap_free(git_offmap *map);
18 void git_offmap_clear(git_offmap *map);
19
20 size_t git_offmap_num_entries(git_offmap *map);
21
22 size_t git_offmap_lookup_index(git_offmap *map, const git_off_t key);
23 int git_offmap_valid_index(git_offmap *map, size_t idx);
24
25 int git_offmap_exists(git_offmap *map, const git_off_t key);
26 int git_offmap_has_data(git_offmap *map, size_t idx);
27
28 git_off_t git_offmap_key_at(git_offmap *map, size_t idx);
29 void *git_offmap_value_at(git_offmap *map, size_t idx);
30 void git_offmap_set_value_at(git_offmap *map, size_t idx, void *value);
31 void git_offmap_delete_at(git_offmap *map, size_t idx);
32
33 int git_offmap_put(git_offmap *map, const git_off_t key, int *err);
34 void git_offmap_insert(git_offmap *map, const git_off_t key, void *value, int *rval);
35 void git_offmap_delete(git_offmap *map, const git_off_t key);
36
37 size_t git_offmap_begin(git_offmap *map);
38 size_t git_offmap_end(git_offmap *map);
39
40 #define git_offmap_foreach(h, kvar, vvar, code) { size_t __i; \
41 for (__i = git_offmap_begin(h); __i != git_offmap_end(h); ++__i) { \
42 if (!git_offmap_has_data(h,__i)) continue; \
43 (kvar) = git_offmap_key_at(h,__i); \
44 (vvar) = git_offmap_value_at(h,__i); \
45 code; \
46 } }
47
48 #define git_offmap_foreach_value(h, vvar, code) { size_t __i; \
49 for (__i = git_offmap_begin(h); __i != git_offmap_end(h); ++__i) { \
50 if (!git_offmap_has_data(h,__i)) continue; \
51 (vvar) = git_offmap_value_at(h,__i); \
52 code; \
53 } }
54
55 #endif