Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
659f5d07
Commit
659f5d07
authored
Jan 27, 2017
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oidmap: convert macros to functions
parent
13c3bc9a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
22 deletions
+115
-22
src/oidmap.c
+98
-0
src/oidmap.h
+17
-22
No files found.
src/oidmap.c
0 → 100644
View file @
659f5d07
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#include "oidmap.h"
__KHASH_IMPL
(
oid
,
static
kh_inline
,
const
git_oid
*
,
void
*
,
1
,
git_oidmap_hash
,
git_oid_equal
)
git_oidmap
*
git_oidmap_alloc
()
{
return
kh_init
(
oid
);
}
void
git_oidmap__free
(
git_oidmap
*
map
)
{
kh_destroy
(
oid
,
map
);
}
void
git_oidmap_clear
(
git_oidmap
*
map
)
{
kh_clear
(
oid
,
map
);
}
size_t
git_oidmap_size
(
git_oidmap
*
map
)
{
return
kh_size
(
map
);
}
size_t
git_oidmap_lookup_index
(
git_oidmap
*
map
,
const
git_oid
*
key
)
{
return
kh_get
(
oid
,
map
,
key
);
}
int
git_oidmap_valid_index
(
git_oidmap
*
map
,
size_t
idx
)
{
return
idx
!=
kh_end
(
map
);
}
int
git_oidmap_exists
(
git_oidmap
*
map
,
const
git_oid
*
key
)
{
return
kh_get
(
oid
,
map
,
key
)
!=
kh_end
(
map
);
}
int
git_oidmap_has_data
(
git_oidmap
*
map
,
size_t
idx
)
{
return
kh_exist
(
map
,
idx
);
}
const
git_oid
*
git_oidmap_key
(
git_oidmap
*
map
,
size_t
idx
)
{
return
kh_key
(
map
,
idx
);
}
void
git_oidmap_set_key_at
(
git_oidmap
*
map
,
size_t
idx
,
git_oid
*
key
)
{
kh_key
(
map
,
idx
)
=
key
;
}
void
*
git_oidmap_value_at
(
git_oidmap
*
map
,
size_t
idx
)
{
return
kh_val
(
map
,
idx
);
}
void
git_oidmap_set_value_at
(
git_oidmap
*
map
,
size_t
idx
,
void
*
value
)
{
kh_val
(
map
,
idx
)
=
value
;
}
void
git_oidmap_delete_at
(
git_oidmap
*
map
,
size_t
idx
)
{
kh_del
(
oid
,
map
,
idx
);
}
int
git_oidmap_put
(
git_oidmap
*
map
,
const
git_oid
*
key
,
int
*
err
)
{
return
kh_put
(
oid
,
map
,
key
,
err
);
}
void
git_oidmap_insert
(
git_oidmap
*
map
,
const
git_oid
*
key
,
void
*
value
,
int
*
rval
)
{
khiter_t
idx
=
kh_put
(
oid
,
map
,
key
,
rval
);
if
((
*
rval
)
>=
0
)
{
if
((
*
rval
)
==
0
)
kh_key
(
map
,
idx
)
=
key
;
kh_val
(
map
,
idx
)
=
value
;
}
}
void
git_oidmap_delete
(
git_oidmap
*
map
,
const
git_oid
*
key
)
{
khiter_t
idx
=
git_oidmap_lookup_index
(
map
,
key
);
if
(
git_oidmap_valid_index
(
map
,
idx
))
git_oidmap_delete_at
(
map
,
idx
);
}
src/oidmap.h
View file @
659f5d07
...
...
@@ -30,37 +30,32 @@ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
#define GIT__USE_OIDMAP \
__KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, git_oidmap_hash, git_oid_equal)
#define git_oidmap_alloc() kh_init(oid)
#define git_oidmap_free(h) kh_destroy(oid,h), h = NULL
git_oidmap
*
git_oidmap_alloc
(
void
);
#define git_oidmap_free(h) git_oidmap__free(h); (h) = NULL
void
git_oidmap__free
(
git_oidmap
*
map
);
void
git_oidmap_clear
(
git_oidmap
*
map
);
#define git_oidmap_lookup_index(h, k) kh_get(oid, h, k)
#define git_oidmap_valid_index(h, idx) (idx != kh_end(h))
size_t
git_oidmap_size
(
git_oidmap
*
map
);
#define git_oidmap_exists(h, k) (kh_get(oid, h, k) != kh_end(h))
#define git_oidmap_has_data(h, idx) kh_exist(h, idx)
size_t
git_oidmap_lookup_index
(
git_oidmap
*
map
,
const
git_oid
*
key
);
int
git_oidmap_valid_index
(
git_oidmap
*
map
,
size_t
idx
);
#define git_oidmap_key(h, idx) kh_key(h, idx)
#define git_oidmap_set_key_at(h, idx, k) kh_key(h, idx) = k
#define git_oidmap_value_at(h, idx) kh_val(h, idx)
#define git_oidmap_set_value_at(h, idx, v) kh_val(h, idx) = v
#define git_oidmap_delete_at(h, idx) kh_del(oid, h, idx)
int
git_oidmap_exists
(
git_oidmap
*
map
,
const
git_oid
*
key
);
int
git_oidmap_has_data
(
git_oidmap
*
map
,
size_t
idx
);
#define git_oidmap_put(h, k, err) kh_put(oid, h, k, err)
const
git_oid
*
git_oidmap_key
(
git_oidmap
*
map
,
size_t
idx
);
void
git_oidmap_set_key_at
(
git_oidmap
*
map
,
size_t
idx
,
git_oid
*
key
);
void
*
git_oidmap_value_at
(
git_oidmap
*
map
,
size_t
idx
);
void
git_oidmap_set_value_at
(
git_oidmap
*
map
,
size_t
idx
,
void
*
value
);
void
git_oidmap_delete_at
(
git_oidmap
*
map
,
size_t
idx
);
#define git_oidmap_insert(h, key, val, rval) do { \
khiter_t __pos = kh_put(oid, h, key, rval); \
if ((*rval) >= 0) { \
if ((*rval) == 0) kh_key(h, __pos) = key; \
kh_val(h, __pos) = val; \
} } while (0)
int
git_oidmap_put
(
git_oidmap
*
map
,
const
git_oid
*
key
,
int
*
err
);
void
git_oidmap_insert
(
git_oidmap
*
map
,
const
git_oid
*
key
,
void
*
value
,
int
*
rval
);
void
git_oidmap_delete
(
git_oidmap
*
map
,
const
git_oid
*
key
);
#define git_oidmap_foreach_value kh_foreach_value
#define git_oidmap_begin kh_begin
#define git_oidmap_end kh_end
#define git_oidmap_size(h) kh_size(h)
#define git_oidmap_clear(h) kh_clear(oid, h)
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment