]> git.proxmox.com Git - libgit2.git/blob - src/offmap.h
treebuilder: fix memory leaks in `write_with_buffer`
[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 #include "git2/types.h"
12
13 #define kmalloc git__malloc
14 #define kcalloc git__calloc
15 #define krealloc git__realloc
16 #define kreallocarray git__reallocarray
17 #define kfree git__free
18 #include "khash.h"
19
20 __KHASH_TYPE(off, git_off_t, void *)
21 typedef khash_t(off) git_offmap;
22
23 git_offmap *git_offmap_alloc(void);
24 void git_offmap_free(git_offmap *map);
25 void git_offmap_clear(git_offmap *map);
26
27 size_t git_offmap_num_entries(git_offmap *map);
28
29 size_t git_offmap_lookup_index(git_offmap *map, const git_off_t key);
30 int git_offmap_valid_index(git_offmap *map, size_t idx);
31
32 int git_offmap_exists(git_offmap *map, const git_off_t key);
33
34 void *git_offmap_value_at(git_offmap *map, size_t idx);
35 void git_offmap_set_value_at(git_offmap *map, size_t idx, void *value);
36 void git_offmap_delete_at(git_offmap *map, size_t idx);
37
38 int git_offmap_put(git_offmap *map, const git_off_t key, int *err);
39 void git_offmap_insert(git_offmap *map, const git_off_t key, void *value, int *rval);
40 void git_offmap_delete(git_offmap *map, const git_off_t key);
41
42 #define git_offmap_foreach kh_foreach
43 #define git_offmap_foreach_value kh_foreach_value
44
45 #endif