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
3f2bf4d6
Commit
3f2bf4d6
authored
Jan 19, 2012
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hashtable: add remove2 to retrieve the value that was removed
parent
d0ec3fb8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
src/hashtable.c
+2
-1
src/hashtable.h
+9
-1
No files found.
src/hashtable.c
View file @
3f2bf4d6
...
...
@@ -213,7 +213,7 @@ void *git_hashtable_lookup(git_hashtable *self, const void *key)
return
NULL
;
}
int
git_hashtable_remove
(
git_hashtable
*
self
,
const
void
*
key
)
int
git_hashtable_remove
2
(
git_hashtable
*
self
,
const
void
*
key
,
void
**
old_value
)
{
int
hash_id
;
git_hashtable_node
*
node
;
...
...
@@ -223,6 +223,7 @@ int git_hashtable_remove(git_hashtable *self, const void *key)
for
(
hash_id
=
0
;
hash_id
<
GIT_HASHTABLE_HASHES
;
++
hash_id
)
{
node
=
node_with_hash
(
self
,
key
,
hash_id
);
if
(
node
->
key
&&
self
->
key_equal
(
key
,
node
->
key
)
==
0
)
{
*
old_value
=
node
->
value
;
node
->
key
=
NULL
;
node
->
value
=
NULL
;
self
->
key_count
--
;
...
...
src/hashtable.h
View file @
3f2bf4d6
...
...
@@ -42,7 +42,15 @@ git_hashtable *git_hashtable_alloc(size_t min_size,
git_hash_ptr
hash
,
git_hash_keyeq_ptr
key_eq
);
void
*
git_hashtable_lookup
(
git_hashtable
*
h
,
const
void
*
key
);
int
git_hashtable_remove
(
git_hashtable
*
table
,
const
void
*
key
);
int
git_hashtable_remove2
(
git_hashtable
*
table
,
const
void
*
key
,
void
**
old_value
);
GIT_INLINE
(
int
)
git_hashtable_remove
(
git_hashtable
*
table
,
const
void
*
key
)
{
void
*
_unused
;
return
git_hashtable_remove2
(
table
,
key
,
&
_unused
);
}
void
git_hashtable_free
(
git_hashtable
*
h
);
void
git_hashtable_clear
(
git_hashtable
*
h
);
int
git_hashtable_merge
(
git_hashtable
*
self
,
git_hashtable
*
other
);
...
...
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