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
24ecf18e
Commit
24ecf18e
authored
Mar 31, 2016
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3717 from libgit2/ethomson/leaks
Plug some leaks
parents
1694a639
c4aa5c04
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
60 additions
and
9 deletions
+60
-9
src/iterator.c
+36
-6
src/tree.c
+2
-0
src/xdiff/xprepare.c
+1
-1
tests/config/write.c
+3
-0
tests/core/array.c
+2
-0
tests/iterator/index.c
+2
-0
tests/iterator/tree.c
+4
-0
tests/iterator/workdir.c
+2
-0
tests/status/worktree.c
+8
-2
No files found.
src/iterator.c
View file @
24ecf18e
...
@@ -408,6 +408,9 @@ typedef struct {
...
@@ -408,6 +408,9 @@ typedef struct {
typedef
struct
{
typedef
struct
{
git_tree
*
tree
;
git_tree
*
tree
;
/* path to this particular frame (folder) */
git_buf
path
;
/* a sorted list of the entries for this frame (folder), these are
/* a sorted list of the entries for this frame (folder), these are
* actually pointers to the iterator's entry pool.
* actually pointers to the iterator's entry pool.
*/
*/
...
@@ -416,13 +419,13 @@ typedef struct {
...
@@ -416,13 +419,13 @@ typedef struct {
size_t
next_idx
;
size_t
next_idx
;
/*
the path to this particular frame (folder); on case insensitive
/*
on case insensitive iterations, we also have an array of other
*
iterations, we also have an array of other paths that we were
*
paths that were case insensitively equal to this one, and their
*
case insensitively equal to this one, whose contents we have
*
tree objects. we have coalesced the tree entries into this frame.
*
coalesced into this frame. a child `tree_iterator_entry` wil
l
*
a child `tree_iterator_entry` will contain a pointer to its actua
l
*
contain a pointer to its actual
parent path.
* parent path.
*/
*/
git_
buf
path
;
git_
vector
similar_trees
;
git_array_t
(
git_buf
)
similar_paths
;
git_array_t
(
git_buf
)
similar_paths
;
}
tree_iterator_frame
;
}
tree_iterator_frame
;
...
@@ -604,6 +607,9 @@ GIT_INLINE(int) tree_iterator_frame_push_neighbors(
...
@@ -604,6 +607,9 @@ GIT_INLINE(int) tree_iterator_frame_push_neighbors(
iter
->
base
.
repo
,
entry
->
tree_entry
->
oid
))
<
0
)
iter
->
base
.
repo
,
entry
->
tree_entry
->
oid
))
<
0
)
break
;
break
;
if
(
git_vector_insert
(
&
parent_frame
->
similar_trees
,
tree
)
<
0
)
break
;
path
=
git_array_alloc
(
parent_frame
->
similar_paths
);
path
=
git_array_alloc
(
parent_frame
->
similar_paths
);
GITERR_CHECK_ALLOC
(
path
);
GITERR_CHECK_ALLOC
(
path
);
...
@@ -667,6 +673,9 @@ done:
...
@@ -667,6 +673,9 @@ done:
static
void
tree_iterator_frame_pop
(
tree_iterator
*
iter
)
static
void
tree_iterator_frame_pop
(
tree_iterator
*
iter
)
{
{
tree_iterator_frame
*
frame
;
tree_iterator_frame
*
frame
;
git_buf
*
buf
=
NULL
;
git_tree
*
tree
;
size_t
i
;
assert
(
iter
->
frames
.
size
);
assert
(
iter
->
frames
.
size
);
...
@@ -674,6 +683,20 @@ static void tree_iterator_frame_pop(tree_iterator *iter)
...
@@ -674,6 +683,20 @@ static void tree_iterator_frame_pop(tree_iterator *iter)
git_vector_free
(
&
frame
->
entries
);
git_vector_free
(
&
frame
->
entries
);
git_tree_free
(
frame
->
tree
);
git_tree_free
(
frame
->
tree
);
do
{
buf
=
git_array_pop
(
frame
->
similar_paths
);
git_buf_free
(
buf
);
}
while
(
buf
!=
NULL
);
git_array_clear
(
frame
->
similar_paths
);
git_vector_foreach
(
&
frame
->
similar_trees
,
i
,
tree
)
git_tree_free
(
tree
);
git_vector_free
(
&
frame
->
similar_trees
);
git_buf_free
(
&
frame
->
path
);
}
}
static
int
tree_iterator_current
(
static
int
tree_iterator_current
(
...
@@ -1760,6 +1783,11 @@ static int filesystem_iterator_reset(git_iterator *i)
...
@@ -1760,6 +1783,11 @@ static int filesystem_iterator_reset(git_iterator *i)
static
void
filesystem_iterator_free
(
git_iterator
*
i
)
static
void
filesystem_iterator_free
(
git_iterator
*
i
)
{
{
filesystem_iterator
*
iter
=
(
filesystem_iterator
*
)
i
;
filesystem_iterator
*
iter
=
(
filesystem_iterator
*
)
i
;
git__free
(
iter
->
root
);
git_buf_free
(
&
iter
->
current_path
);
git_tree_free
(
iter
->
tree
);
if
(
iter
->
index
)
git_index_snapshot_release
(
&
iter
->
index_snapshot
,
iter
->
index
);
filesystem_iterator_clear
(
iter
);
filesystem_iterator_clear
(
iter
);
}
}
...
@@ -1823,6 +1851,7 @@ static int iterator_for_filesystem(
...
@@ -1823,6 +1851,7 @@ static int iterator_for_filesystem(
(
error
=
git_index_snapshot_new
(
&
iter
->
index_snapshot
,
index
))
<
0
)
(
error
=
git_index_snapshot_new
(
&
iter
->
index_snapshot
,
index
))
<
0
)
goto
on_error
;
goto
on_error
;
iter
->
index
=
index
;
iter
->
dirload_flags
=
iter
->
dirload_flags
=
(
iterator__ignore_case
(
&
iter
->
base
)
?
GIT_PATH_DIR_IGNORE_CASE
:
0
)
|
(
iterator__ignore_case
(
&
iter
->
base
)
?
GIT_PATH_DIR_IGNORE_CASE
:
0
)
|
(
iterator__flag
(
&
iter
->
base
,
PRECOMPOSE_UNICODE
)
?
(
iterator__flag
(
&
iter
->
base
,
PRECOMPOSE_UNICODE
)
?
...
@@ -2093,6 +2122,7 @@ static void index_iterator_free(git_iterator *i)
...
@@ -2093,6 +2122,7 @@ static void index_iterator_free(git_iterator *i)
index_iterator
*
iter
=
(
index_iterator
*
)
i
;
index_iterator
*
iter
=
(
index_iterator
*
)
i
;
git_index_snapshot_release
(
&
iter
->
entries
,
iter
->
base
.
index
);
git_index_snapshot_release
(
&
iter
->
entries
,
iter
->
base
.
index
);
git_buf_free
(
&
iter
->
tree_buf
);
}
}
int
git_iterator_for_index
(
int
git_iterator_for_index
(
...
...
src/tree.c
View file @
24ecf18e
...
@@ -837,6 +837,8 @@ int git_treebuilder_write(git_oid *oid, git_treebuilder *bld)
...
@@ -837,6 +837,8 @@ int git_treebuilder_write(git_oid *oid, git_treebuilder *bld)
error
=
git_odb_write
(
oid
,
odb
,
tree
.
ptr
,
tree
.
size
,
GIT_OBJ_TREE
);
error
=
git_odb_write
(
oid
,
odb
,
tree
.
ptr
,
tree
.
size
,
GIT_OBJ_TREE
);
git_buf_free
(
&
tree
);
git_buf_free
(
&
tree
);
git_vector_free
(
&
entries
);
return
error
;
return
error
;
}
}
...
...
src/xdiff/xprepare.c
View file @
24ecf18e
...
@@ -305,7 +305,7 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
...
@@ -305,7 +305,7 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
return
-
1
;
return
-
1
;
}
}
if
(
XDF_DIFF_ALG
(
(
xpp
->
flags
)
&
XDF_HISTOGRAM_DIFF
)
)
if
(
XDF_DIFF_ALG
(
xpp
->
flags
)
!=
XDF_HISTOGRAM_DIFF
)
xdl_free_classifier
(
&
cf
);
xdl_free_classifier
(
&
cf
);
return
0
;
return
0
;
...
...
tests/config/write.c
View file @
24ecf18e
...
@@ -712,10 +712,13 @@ void test_config_write__repeated(void)
...
@@ -712,10 +712,13 @@ void test_config_write__repeated(void)
cl_git_pass
(
git_config_set_string
(
cfg
,
"sample.prefix.setting2"
,
"someValue2"
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"sample.prefix.setting2"
,
"someValue2"
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"sample.prefix.setting3"
,
"someValue3"
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"sample.prefix.setting3"
,
"someValue3"
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"sample.prefix.setting4"
,
"someValue4"
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"sample.prefix.setting4"
,
"someValue4"
));
git_config_free
(
cfg
);
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
filename
));
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
filename
));
cl_git_pass
(
git_futils_readbuffer
(
&
result
,
filename
));
cl_git_pass
(
git_futils_readbuffer
(
&
result
,
filename
));
cl_assert_equal_s
(
expected
,
result
.
ptr
);
cl_assert_equal_s
(
expected
,
result
.
ptr
);
git_buf_free
(
&
result
);
git_buf_free
(
&
result
);
git_config_free
(
cfg
);
}
}
tests/core/array.c
View file @
24ecf18e
...
@@ -51,5 +51,7 @@ void test_core_array__bsearch2(void)
...
@@ -51,5 +51,7 @@ void test_core_array__bsearch2(void)
expect_pos
(
50
,
10
,
GIT_ENOTFOUND
);
expect_pos
(
50
,
10
,
GIT_ENOTFOUND
);
expect_pos
(
68
,
10
,
GIT_ENOTFOUND
);
expect_pos
(
68
,
10
,
GIT_ENOTFOUND
);
expect_pos
(
256
,
12
,
GIT_OK
);
expect_pos
(
256
,
12
,
GIT_OK
);
git_array_clear
(
integers
);
}
}
tests/iterator/index.c
View file @
24ecf18e
...
@@ -970,7 +970,9 @@ void test_iterator_index__pathlist_with_directory(void)
...
@@ -970,7 +970,9 @@ void test_iterator_index__pathlist_with_directory(void)
cl_git_pass
(
git_iterator_for_index
(
&
i
,
g_repo
,
index
,
&
i_opts
));
cl_git_pass
(
git_iterator_for_index
(
&
i
,
g_repo
,
index
,
&
i_opts
));
expect_iterator_items
(
i
,
4
,
NULL
,
4
,
NULL
);
expect_iterator_items
(
i
,
4
,
NULL
,
4
,
NULL
);
git_iterator_free
(
i
);
git_iterator_free
(
i
);
git_index_free
(
index
);
git_index_free
(
index
);
git_tree_free
(
tree
);
git_vector_free
(
&
filelist
);
git_vector_free
(
&
filelist
);
}
}
...
...
tests/iterator/tree.c
View file @
24ecf18e
...
@@ -1020,6 +1020,7 @@ void test_iterator_tree__pathlist_with_directory(void)
...
@@ -1020,6 +1020,7 @@ void test_iterator_tree__pathlist_with_directory(void)
expect_iterator_items
(
i
,
expected_len2
,
expected2
,
expected_len2
,
expected2
);
expect_iterator_items
(
i
,
expected_len2
,
expected2
,
expected_len2
,
expected2
);
git_iterator_free
(
i
);
git_iterator_free
(
i
);
git_tree_free
(
tree
);
git_vector_free
(
&
filelist
);
git_vector_free
(
&
filelist
);
}
}
...
@@ -1048,6 +1049,7 @@ void test_iterator_tree__pathlist_with_directory_include_tree_nodes(void)
...
@@ -1048,6 +1049,7 @@ void test_iterator_tree__pathlist_with_directory_include_tree_nodes(void)
expect_iterator_items
(
i
,
expected_len
,
expected
,
expected_len
,
expected
);
expect_iterator_items
(
i
,
expected_len
,
expected
,
expected_len
,
expected
);
git_iterator_free
(
i
);
git_iterator_free
(
i
);
git_tree_free
(
tree
);
git_vector_free
(
&
filelist
);
git_vector_free
(
&
filelist
);
}
}
...
@@ -1070,7 +1072,9 @@ void test_iterator_tree__pathlist_no_match(void)
...
@@ -1070,7 +1072,9 @@ void test_iterator_tree__pathlist_no_match(void)
cl_git_pass
(
git_iterator_for_tree
(
&
i
,
tree
,
&
i_opts
));
cl_git_pass
(
git_iterator_for_tree
(
&
i
,
tree
,
&
i_opts
));
cl_assert_equal_i
(
GIT_ITEROVER
,
git_iterator_current
(
&
entry
,
i
));
cl_assert_equal_i
(
GIT_ITEROVER
,
git_iterator_current
(
&
entry
,
i
));
git_iterator_free
(
i
);
git_tree_free
(
tree
);
git_vector_free
(
&
filelist
);
git_vector_free
(
&
filelist
);
}
}
tests/iterator/workdir.c
View file @
24ecf18e
...
@@ -1030,6 +1030,8 @@ static void create_paths(const char *root, int depth)
...
@@ -1030,6 +1030,8 @@ static void create_paths(const char *root, int depth)
create_paths
(
fullpath
.
ptr
,
(
depth
-
1
));
create_paths
(
fullpath
.
ptr
,
(
depth
-
1
));
}
}
}
}
git_buf_free
(
&
fullpath
);
}
}
void
test_iterator_workdir__pathlist_for_deeply_nested_item
(
void
)
void
test_iterator_workdir__pathlist_for_deeply_nested_item
(
void
)
...
...
tests/status/worktree.c
View file @
24ecf18e
...
@@ -1211,15 +1211,15 @@ void test_status_worktree__with_directory_in_pathlist(void)
...
@@ -1211,15 +1211,15 @@ void test_status_worktree__with_directory_in_pathlist(void)
const
git_status_entry
*
status
;
const
git_status_entry
*
status
;
size_t
i
,
entrycount
;
size_t
i
,
entrycount
;
bool
native_ignore_case
;
bool
native_ignore_case
;
char
*
subdir_path
=
"subdir"
;
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
native_ignore_case
=
native_ignore_case
=
(
git_index_caps
(
index
)
&
GIT_INDEXCAP_IGNORE_CASE
)
!=
0
;
(
git_index_caps
(
index
)
&
GIT_INDEXCAP_IGNORE_CASE
)
!=
0
;
git_index_free
(
index
);
git_index_free
(
index
);
opts
.
pathspec
.
strings
=
&
subdir_path
;
opts
.
pathspec
.
count
=
1
;
opts
.
pathspec
.
count
=
1
;
opts
.
pathspec
.
strings
=
malloc
(
opts
.
pathspec
.
count
*
sizeof
(
char
*
));
opts
.
pathspec
.
strings
[
0
]
=
"subdir"
;
opts
.
flags
=
opts
.
flags
=
GIT_STATUS_OPT_DEFAULTS
|
GIT_STATUS_OPT_DEFAULTS
|
GIT_STATUS_OPT_INCLUDE_UNMODIFIED
|
GIT_STATUS_OPT_INCLUDE_UNMODIFIED
|
...
@@ -1240,6 +1240,8 @@ void test_status_worktree__with_directory_in_pathlist(void)
...
@@ -1240,6 +1240,8 @@ void test_status_worktree__with_directory_in_pathlist(void)
status
->
index_to_workdir
->
old_file
.
path
);
status
->
index_to_workdir
->
old_file
.
path
);
}
}
git_status_list_free
(
statuslist
);
opts
.
show
=
GIT_STATUS_SHOW_INDEX_ONLY
;
opts
.
show
=
GIT_STATUS_SHOW_INDEX_ONLY
;
git_status_list_new
(
&
statuslist
,
repo
,
&
opts
);
git_status_list_new
(
&
statuslist
,
repo
,
&
opts
);
...
@@ -1255,6 +1257,8 @@ void test_status_worktree__with_directory_in_pathlist(void)
...
@@ -1255,6 +1257,8 @@ void test_status_worktree__with_directory_in_pathlist(void)
status
->
head_to_index
->
old_file
.
path
);
status
->
head_to_index
->
old_file
.
path
);
}
}
git_status_list_free
(
statuslist
);
opts
.
show
=
GIT_STATUS_SHOW_INDEX_AND_WORKDIR
;
opts
.
show
=
GIT_STATUS_SHOW_INDEX_AND_WORKDIR
;
git_status_list_new
(
&
statuslist
,
repo
,
&
opts
);
git_status_list_new
(
&
statuslist
,
repo
,
&
opts
);
...
@@ -1269,5 +1273,7 @@ void test_status_worktree__with_directory_in_pathlist(void)
...
@@ -1269,5 +1273,7 @@ void test_status_worktree__with_directory_in_pathlist(void)
testrepo2_subdir_paths
[
i
],
testrepo2_subdir_paths
[
i
],
status
->
index_to_workdir
->
old_file
.
path
);
status
->
index_to_workdir
->
old_file
.
path
);
}
}
git_status_list_free
(
statuslist
);
}
}
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