]> git.proxmox.com Git - libgit2.git/blame - src/oidmap.h
Oh yeah, bugs from my rebase
[libgit2.git] / src / oidmap.h
CommitLineData
01fed0a8
RB
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 */
c2b67043
RB
7#ifndef INCLUDE_oidmap_h__
8#define INCLUDE_oidmap_h__
01fed0a8
RB
9
10#include "common.h"
11#include "git2/oid.h"
12
13#define kmalloc git__malloc
14#define kcalloc git__calloc
15#define krealloc git__realloc
16#define kfree git__free
17#include "khash.h"
18
19__KHASH_TYPE(oid, const git_oid *, void *);
c2b67043 20typedef khash_t(oid) git_oidmap;
01fed0a8
RB
21
22GIT_INLINE(khint_t) hash_git_oid(const git_oid *oid)
23{
24 int i;
25 khint_t h = 0;
26 for (i = 0; i < 20; ++i)
27 h = (h << 5) - h + oid->id[i];
28 return h;
29}
30
c2b67043 31#define GIT__USE_OIDMAP \
f6b26e77 32 __KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, hash_git_oid, git_oid_equal)
01fed0a8 33
c2b67043
RB
34#define git_oidmap_alloc() kh_init(oid)
35#define git_oidmap_free(h) kh_destroy(oid,h), h = NULL
01fed0a8
RB
36
37#endif