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
dca6b228
Commit
dca6b228
authored
Jun 20, 2012
by
Michael Schubert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notes: fix memory leaks
parent
9311423c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
src/notes.c
+8
-12
tests-clar/notes/notes.c
+2
-0
No files found.
src/notes.c
View file @
dca6b228
...
@@ -56,7 +56,7 @@ static int find_subtree_r(git_tree **out, git_tree *root,
...
@@ -56,7 +56,7 @@ static int find_subtree_r(git_tree **out, git_tree *root,
error
=
find_subtree_in_current_level
(
&
subtree
,
repo
,
root
,
target
,
*
fanout
);
error
=
find_subtree_in_current_level
(
&
subtree
,
repo
,
root
,
target
,
*
fanout
);
if
(
error
==
GIT_EEXISTS
)
{
if
(
error
==
GIT_EEXISTS
)
{
return
git_tree_lookup
(
out
,
repo
,
git_
object_id
((
const
git_object
*
)
root
));
return
git_tree_lookup
(
out
,
repo
,
git_
tree_id
(
root
));
}
}
if
(
error
<
0
)
if
(
error
<
0
)
...
@@ -64,13 +64,7 @@ static int find_subtree_r(git_tree **out, git_tree *root,
...
@@ -64,13 +64,7 @@ static int find_subtree_r(git_tree **out, git_tree *root,
*
fanout
+=
2
;
*
fanout
+=
2
;
error
=
find_subtree_r
(
out
,
subtree
,
repo
,
target
,
fanout
);
error
=
find_subtree_r
(
out
,
subtree
,
repo
,
target
,
fanout
);
git_tree_free
(
subtree
);
/*
* root is not ours to free, and the last subtree is the
* one being returned => we only need to free the subtrees in-between
*/
if
(
*
out
!=
subtree
)
git_tree_free
(
subtree
);
return
error
;
return
error
;
}
}
...
@@ -153,7 +147,7 @@ static int manipulate_note_in_tree_r(
...
@@ -153,7 +147,7 @@ static int manipulate_note_in_tree_r(
int
current_error
))
int
current_error
))
{
{
int
error
=
-
1
;
int
error
=
-
1
;
git_tree
*
subtree
=
NULL
;
git_tree
*
subtree
=
NULL
,
*
new
=
NULL
;
char
subtree_name
[
3
];
char
subtree_name
[
3
];
error
=
find_subtree_in_current_level
(
error
=
find_subtree_in_current_level
(
...
@@ -176,7 +170,7 @@ static int manipulate_note_in_tree_r(
...
@@ -176,7 +170,7 @@ static int manipulate_note_in_tree_r(
/* An existing fanout has been found, let's dig deeper */
/* An existing fanout has been found, let's dig deeper */
error
=
manipulate_note_in_tree_r
(
error
=
manipulate_note_in_tree_r
(
out
,
repo
,
subtree
,
note_oid
,
annotated_object_sha
,
&
new
,
repo
,
subtree
,
note_oid
,
annotated_object_sha
,
fanout
+
2
,
note_exists_cb
,
note_notfound_cb
);
fanout
+
2
,
note_exists_cb
,
note_notfound_cb
);
if
(
error
<
0
)
if
(
error
<
0
)
...
@@ -185,10 +179,12 @@ static int manipulate_note_in_tree_r(
...
@@ -185,10 +179,12 @@ static int manipulate_note_in_tree_r(
strncpy
(
subtree_name
,
annotated_object_sha
+
fanout
,
2
);
strncpy
(
subtree_name
,
annotated_object_sha
+
fanout
,
2
);
subtree_name
[
2
]
=
'\0'
;
subtree_name
[
2
]
=
'\0'
;
error
=
tree_write
(
out
,
repo
,
parent
,
error
=
tree_write
(
out
,
repo
,
parent
,
git_tree_id
(
new
),
git_object_id
((
const
git_object
*
)(
*
out
)),
subtree_name
,
0040000
);
subtree_name
,
0040000
);
cleanup:
cleanup:
git_tree_free
(
new
);
git_tree_free
(
subtree
);
git_tree_free
(
subtree
);
return
error
;
return
error
;
}
}
...
...
tests-clar/notes/notes.c
View file @
dca6b228
...
@@ -23,6 +23,8 @@ static void assert_note_equal(git_note *note, char *message, git_oid *note_oid)
...
@@ -23,6 +23,8 @@ static void assert_note_equal(git_note *note, char *message, git_oid *note_oid)
cl_git_pass
(
git_blob_lookup
(
&
blob
,
_repo
,
note_oid
));
cl_git_pass
(
git_blob_lookup
(
&
blob
,
_repo
,
note_oid
));
cl_assert_equal_s
(
git_note_message
(
note
),
(
const
char
*
)
git_blob_rawcontent
(
blob
));
cl_assert_equal_s
(
git_note_message
(
note
),
(
const
char
*
)
git_blob_rawcontent
(
blob
));
git_blob_free
(
blob
);
}
}
static
void
create_note
(
git_oid
*
note_oid
,
const
char
*
canonical_namespace
,
const
char
*
target_sha
,
const
char
*
message
)
static
void
create_note
(
git_oid
*
note_oid
,
const
char
*
canonical_namespace
,
const
char
*
target_sha
,
const
char
*
message
)
...
...
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