]> git.proxmox.com Git - libgit2.git/blame - src/offmap.h
offmap: convert to use functions instead of macros
[libgit2.git] / src / offmap.h
CommitLineData
c0f4a011
CMN
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
650e45f6 16#define kreallocarray git__reallocarray
c0f4a011
CMN
17#define kfree git__free
18#include "khash.h"
19
c8e02b87 20__KHASH_TYPE(off, git_off_t, void *)
c0f4a011
CMN
21typedef khash_t(off) git_offmap;
22
23#define GIT__USE_OFFMAP \
c8e02b87 24 __KHASH_IMPL(off, static kh_inline, git_off_t, void *, 1, kh_int64_hash_func, kh_int64_hash_equal)
c0f4a011 25
cf6124d6
PS
26git_offmap *git_offmap_alloc(void);
27#define git_offmap_free(h) git_offmap__free(h); (h) = NULL
28void git_offmap__free(git_offmap *map);
29void git_offmap_clear(git_offmap *map);
c0f4a011 30
cf6124d6 31size_t git_offmap_num_entries(git_offmap *map);
c0f4a011 32
cf6124d6
PS
33size_t git_offmap_lookup_index(git_offmap *map, const git_off_t key);
34int git_offmap_valid_index(git_offmap *map, size_t idx);
c0f4a011 35
cf6124d6 36int git_offmap_exists(git_offmap *map, const git_off_t key);
c0f4a011 37
cf6124d6
PS
38void *git_offmap_value_at(git_offmap *map, size_t idx);
39void git_offmap_set_value_at(git_offmap *map, size_t idx, void *value);
40void git_offmap_delete_at(git_offmap *map, size_t idx);
c0f4a011 41
cf6124d6
PS
42int git_offmap_put(git_offmap *map, const git_off_t key, int *err);
43void git_offmap_insert(git_offmap *map, const git_off_t key, void *value, int *rval);
44void git_offmap_delete(git_offmap *map, const git_off_t key);
c0f4a011
CMN
45
46#define git_offmap_foreach kh_foreach
47#define git_offmap_foreach_value kh_foreach_value
48
49#endif