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
529f342a
Commit
529f342a
authored
Jan 14, 2014
by
Arthur Schreiber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Align git_tree_entry_dup.
parent
29be3a6d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
include/git2/tree.h
+4
-3
src/tree.c
+8
-9
No files found.
include/git2/tree.h
View file @
529f342a
...
@@ -150,10 +150,11 @@ GIT_EXTERN(int) git_tree_entry_bypath(
...
@@ -150,10 +150,11 @@ GIT_EXTERN(int) git_tree_entry_bypath(
* Create a copy of a tree entry. The returned copy is owned by the user,
* Create a copy of a tree entry. The returned copy is owned by the user,
* and must be freed explicitly with `git_tree_entry_free()`.
* and must be freed explicitly with `git_tree_entry_free()`.
*
*
* @param entry A tree entry to duplicate
* @param dest pointer where to store the copy
* @return a copy of the original entry or NULL on error (alloc failure)
* @param entry tree entry to duplicate
* @return 0 or an error code
*/
*/
GIT_EXTERN
(
git_tree_entry
*
)
git_tree_entry_dup
(
const
git_tree_entry
*
entry
);
GIT_EXTERN
(
int
)
git_tree_entry_dup
(
git_tree_entry
**
dest
,
const
git_tree_entry
*
source
);
/**
/**
* Free a user-owned tree entry
* Free a user-owned tree entry
...
...
src/tree.c
View file @
529f342a
...
@@ -204,22 +204,22 @@ void git_tree_entry_free(git_tree_entry *entry)
...
@@ -204,22 +204,22 @@ void git_tree_entry_free(git_tree_entry *entry)
git__free
(
entry
);
git__free
(
entry
);
}
}
git_tree_entry
*
git_tree_entry_dup
(
const
git_tree_entry
*
entry
)
int
git_tree_entry_dup
(
git_tree_entry
**
dest
,
const
git_tree_entry
*
source
)
{
{
size_t
total_size
;
size_t
total_size
;
git_tree_entry
*
copy
;
git_tree_entry
*
copy
;
assert
(
entry
);
assert
(
source
);
total_size
=
sizeof
(
git_tree_entry
)
+
entry
->
filename_len
+
1
;
total_size
=
sizeof
(
git_tree_entry
)
+
source
->
filename_len
+
1
;
copy
=
git__malloc
(
total_size
);
copy
=
git__malloc
(
total_size
);
if
(
!
copy
)
GITERR_CHECK_ALLOC
(
copy
);
return
NULL
;
memcpy
(
copy
,
entry
,
total_size
);
memcpy
(
copy
,
source
,
total_size
);
return
copy
;
*
dest
=
copy
;
return
0
;
}
}
void
git_tree__free
(
void
*
_tree
)
void
git_tree__free
(
void
*
_tree
)
...
@@ -853,8 +853,7 @@ int git_tree_entry_bypath(
...
@@ -853,8 +853,7 @@ int git_tree_entry_bypath(
case
'\0'
:
case
'\0'
:
/* If there are no more components in the path, return
/* If there are no more components in the path, return
* this entry */
* this entry */
*
entry_out
=
git_tree_entry_dup
(
entry
);
return
git_tree_entry_dup
(
entry_out
,
entry
);
return
0
;
}
}
if
(
git_tree_lookup
(
&
subtree
,
root
->
object
.
repo
,
&
entry
->
oid
)
<
0
)
if
(
git_tree_lookup
(
&
subtree
,
root
->
object
.
repo
,
&
entry
->
oid
)
<
0
)
...
...
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