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
f31cb45a
Commit
f31cb45a
authored
Jan 25, 2017
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
khash: avoid using `kh_put` directly
parent
a8cd560b
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
17 additions
and
11 deletions
+17
-11
src/indexer.c
+2
-2
src/odb_mempack.c
+1
-1
src/offmap.h
+2
-0
src/oidmap.h
+2
-0
src/pack-objects.c
+2
-2
src/pack.c
+1
-1
src/revwalk.c
+1
-1
src/sortedcache.c
+1
-1
src/strmap.h
+2
-0
src/submodule.c
+1
-1
tests/core/oidmap.c
+2
-2
No files found.
src/indexer.c
View file @
f31cb45a
...
...
@@ -294,7 +294,7 @@ static int store_object(git_indexer *idx)
git_oid_cpy
(
&
pentry
->
sha1
,
&
oid
);
pentry
->
offset
=
entry_start
;
k
=
kh_put
(
oid
,
idx
->
pack
->
idx_cache
,
&
pentry
->
sha1
,
&
error
);
k
=
git_oidmap_put
(
idx
->
pack
->
idx_cache
,
&
pentry
->
sha1
,
&
error
);
if
(
error
==
-
1
)
{
git__free
(
pentry
);
giterr_set_oom
();
...
...
@@ -349,7 +349,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
}
pentry
->
offset
=
entry_start
;
k
=
kh_put
(
oid
,
idx
->
pack
->
idx_cache
,
&
pentry
->
sha1
,
&
error
);
k
=
git_oidmap_put
(
idx
->
pack
->
idx_cache
,
&
pentry
->
sha1
,
&
error
);
if
(
error
<=
0
)
{
giterr_set
(
GITERR_INDEXER
,
"cannot insert object into pack"
);
...
...
src/odb_mempack.c
View file @
f31cb45a
...
...
@@ -41,7 +41,7 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
size_t
alloc_len
;
int
rval
;
pos
=
kh_put
(
oid
,
db
->
objects
,
oid
,
&
rval
);
pos
=
git_oidmap_put
(
db
->
objects
,
oid
,
&
rval
);
if
(
rval
<
0
)
return
-
1
;
...
...
src/offmap.h
View file @
f31cb45a
...
...
@@ -38,6 +38,8 @@ typedef khash_t(off) git_offmap;
#define git_offmap_set_value_at(h, idx, v) kh_val(h, idx) = v
#define git_offmap_delete_at(h, idx) kh_del(off, h, idx)
#define git_offmap_put(h, k, err) kh_put(off, h, k, err)
#define git_offmap_insert(h, key, val, rval) do { \
khiter_t __pos = kh_put(off, h, key, &rval); \
if (rval >= 0) { \
...
...
src/oidmap.h
View file @
f31cb45a
...
...
@@ -43,6 +43,8 @@ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
#define git_oidmap_value_at(h, idx) kh_val(h, idx)
#define git_oidmap_delete_at(h, idx) kh_del(oid, h, idx)
#define git_oidmap_put(h, k, err) kh_put(oid, h, k, err)
#define git_oidmap_insert(h, key, val, rval) do { \
khiter_t __pos = kh_put(oid, h, key, &rval); \
if (rval >= 0) { \
...
...
src/pack-objects.c
View file @
f31cb45a
...
...
@@ -199,7 +199,7 @@ static void rehash(git_packbuilder *pb)
git_oidmap_clear
(
pb
->
object_ix
);
for
(
i
=
0
,
po
=
pb
->
object_list
;
i
<
pb
->
nr_objects
;
i
++
,
po
++
)
{
pos
=
kh_put
(
oid
,
pb
->
object_ix
,
&
po
->
id
,
&
ret
);
pos
=
git_oidmap_put
(
pb
->
object_ix
,
&
po
->
id
,
&
ret
);
git_oidmap_value_at
(
pb
->
object_ix
,
pos
)
=
po
;
}
}
...
...
@@ -246,7 +246,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
git_oid_cpy
(
&
po
->
id
,
oid
);
po
->
hash
=
name_hash
(
name
);
pos
=
kh_put
(
oid
,
pb
->
object_ix
,
&
po
->
id
,
&
ret
);
pos
=
git_oidmap_put
(
pb
->
object_ix
,
&
po
->
id
,
&
ret
);
if
(
ret
<
0
)
{
giterr_set_oom
();
return
ret
;
...
...
src/pack.c
View file @
f31cb45a
...
...
@@ -169,7 +169,7 @@ static int cache_add(
while
(
cache
->
memory_used
+
base
->
len
>
cache
->
memory_limit
)
free_lowest_entry
(
cache
);
k
=
kh_put
(
off
,
cache
->
entries
,
offset
,
&
error
);
k
=
git_offmap_put
(
cache
->
entries
,
offset
,
&
error
);
assert
(
error
!=
0
);
git_oidmap_value_at
(
cache
->
entries
,
k
)
=
entry
;
cache
->
memory_used
+=
entry
->
raw
.
len
;
...
...
src/revwalk.c
View file @
f31cb45a
...
...
@@ -35,7 +35,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
git_oid_cpy
(
&
commit
->
oid
,
oid
);
pos
=
kh_put
(
oid
,
walk
->
commits
,
&
commit
->
oid
,
&
ret
);
pos
=
git_oidmap_put
(
walk
->
commits
,
&
commit
->
oid
,
&
ret
);
assert
(
ret
!=
0
);
git_oidmap_value_at
(
walk
->
commits
,
pos
)
=
commit
;
...
...
src/sortedcache.c
View file @
f31cb45a
...
...
@@ -294,7 +294,7 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
item_key
=
((
char
*
)
item
)
+
sc
->
item_path_offset
;
memcpy
(
item_key
,
key
,
keylen
);
pos
=
kh_put
(
str
,
sc
->
map
,
item_key
,
&
error
);
pos
=
git_strmap_put
(
sc
->
map
,
item_key
,
&
error
);
if
(
error
<
0
)
goto
done
;
...
...
src/strmap.h
View file @
f31cb45a
...
...
@@ -42,6 +42,8 @@ typedef khiter_t git_strmap_iter;
#define git_strmap_set_value_at(h, idx, v) kh_val(h, idx) = v
#define git_strmap_delete_at(h, idx) kh_del(str, h, idx)
#define git_strmap_put(h, k, err) kh_put(str, h, k, err)
#define git_strmap_insert(h, key, val, rval) do { \
khiter_t __pos = kh_put(str, h, key, &rval); \
if (rval >= 0) { \
...
...
src/submodule.c
View file @
f31cb45a
...
...
@@ -329,7 +329,7 @@ static int submodule_get_or_create(git_submodule **out, git_repository *repo, gi
if
((
error
=
submodule_alloc
(
&
sm
,
repo
,
name
))
<
0
)
return
error
;
pos
=
kh_put
(
str
,
map
,
sm
->
name
,
&
error
);
pos
=
git_strmap_put
(
map
,
sm
->
name
,
&
error
);
/* nobody can beat us to adding it */
assert
(
error
!=
0
);
if
(
error
<
0
)
{
...
...
tests/core/oidmap.c
View file @
f31cb45a
...
...
@@ -36,7 +36,7 @@ void test_core_oidmap__basic(void)
pos
=
git_oidmap_lookup_index
(
map
,
&
items
[
i
].
oid
);
cl_assert
(
!
git_oidmap_valid_index
(
map
,
pos
));
pos
=
kh_put
(
oid
,
map
,
&
items
[
i
].
oid
,
&
ret
);
pos
=
git_oidmap_put
(
map
,
&
items
[
i
].
oid
,
&
ret
);
cl_assert
(
ret
!=
0
);
git_oidmap_value_at
(
map
,
pos
)
=
&
items
[
i
];
...
...
@@ -90,7 +90,7 @@ void test_core_oidmap__hash_collision(void)
pos
=
git_oidmap_lookup_index
(
map
,
&
items
[
i
].
oid
);
cl_assert
(
!
git_oidmap_valid_index
(
map
,
pos
));
pos
=
kh_put
(
oid
,
map
,
&
items
[
i
].
oid
,
&
ret
);
pos
=
git_oidmap_put
(
map
,
&
items
[
i
].
oid
,
&
ret
);
cl_assert
(
ret
!=
0
);
git_oidmap_value_at
(
map
,
pos
)
=
&
items
[
i
];
...
...
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