oidmap.h 867 Bytes
Newer Older
1
/*
Edward Thomson committed
2
 * Copyright (C) the libgit2 contributors. All rights reserved.
3 4 5 6
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */
7 8
#ifndef INCLUDE_oidmap_h__
#define INCLUDE_oidmap_h__
9 10 11 12 13 14 15 16 17 18 19

#include "common.h"
#include "git2/oid.h"

#define kmalloc git__malloc
#define kcalloc git__calloc
#define krealloc git__realloc
#define kfree git__free
#include "khash.h"

__KHASH_TYPE(oid, const git_oid *, void *);
20
typedef khash_t(oid) git_oidmap;
21

22
GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
23
{
24 25
	khint_t h;
	memcpy(&h, oid, sizeof(khint_t));
26 27 28
	return h;
}

29
#define GIT__USE_OIDMAP \
30
	__KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, git_oidmap_hash, git_oid_equal)
31

32 33
#define git_oidmap_alloc() kh_init(oid)
#define git_oidmap_free(h) kh_destroy(oid,h), h = NULL
34 35

#endif