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
86cb34cb
Commit
86cb34cb
authored
Jun 25, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2442 from libgit2/cmn/leaks
Fix a couple of leaks
parents
c61dc1a9
c19b1c04
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
17 deletions
+20
-17
src/mwindow.c
+14
-13
src/mwindow.h
+1
-1
src/pack.c
+3
-3
src/tree.c
+2
-0
No files found.
src/mwindow.c
View file @
86cb34cb
...
...
@@ -62,11 +62,14 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
if
((
error
=
git_packfile__name
(
&
packname
,
path
))
<
0
)
return
error
;
if
(
git_mutex_lock
(
&
git__mwindow_mutex
)
<
0
)
if
(
git_mutex_lock
(
&
git__mwindow_mutex
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"failed to lock mwindow mutex"
);
return
-
1
;
}
if
(
git_mwindow_files_init
()
<
0
)
{
git_mutex_unlock
(
&
git__mwindow_mutex
);
git__free
(
packname
);
return
-
1
;
}
...
...
@@ -93,31 +96,29 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
git_strmap_insert
(
git__pack_cache
,
pack
->
pack_name
,
pack
,
error
);
git_mutex_unlock
(
&
git__mwindow_mutex
);
if
(
error
<
0
)
if
(
error
<
0
)
{
git_packfile_free
(
pack
);
return
-
1
;
}
*
out
=
pack
;
return
0
;
}
int
git_mwindow_put_pack
(
struct
git_pack_file
*
pack
)
void
git_mwindow_put_pack
(
struct
git_pack_file
*
pack
)
{
int
count
;
git_strmap_iter
pos
;
if
(
git_mutex_lock
(
&
git__mwindow_mutex
)
<
0
)
return
-
1
;
return
;
if
(
git_mwindow_files_init
()
<
0
)
{
git_mutex_unlock
(
&
git__mwindow_mutex
);
return
-
1
;
}
/* put before get would be a corrupted state */
assert
(
git__pack_cache
);
pos
=
git_strmap_lookup_index
(
git__pack_cache
,
pack
->
pack_name
);
if
(
!
git_strmap_valid_index
(
git__pack_cache
,
pos
))
{
git_mutex_unlock
(
&
git__mwindow_mutex
);
return
GIT_ENOTFOUND
;
}
/* if we cannot find it, the state is corrupted */
assert
(
git_strmap_valid_index
(
git__pack_cache
,
pos
));
count
=
git_atomic_dec
(
&
pack
->
refcount
);
if
(
count
==
0
)
{
...
...
@@ -126,7 +127,7 @@ int git_mwindow_put_pack(struct git_pack_file *pack)
}
git_mutex_unlock
(
&
git__mwindow_mutex
);
return
0
;
return
;
}
void
git_mwindow_free_all
(
git_mwindow_file
*
mwf
)
...
...
src/mwindow.h
View file @
86cb34cb
...
...
@@ -48,6 +48,6 @@ void git_mwindow_files_free(void);
struct
git_pack_file
;
/* just declaration to avoid cyclical includes */
int
git_mwindow_get_pack
(
struct
git_pack_file
**
out
,
const
char
*
path
);
int
git_mwindow_put_pack
(
struct
git_pack_file
*
pack
);
void
git_mwindow_put_pack
(
struct
git_pack_file
*
pack
);
#endif
src/pack.c
View file @
86cb34cb
...
...
@@ -968,10 +968,10 @@ void git_packfile_free(struct git_pack_file *p)
cache_free
(
&
p
->
bases
);
git_mwindow_free_all_locked
(
&
p
->
mwf
);
if
(
p
->
mwf
.
fd
>=
0
)
if
(
p
->
mwf
.
fd
>=
0
)
{
git_mwindow_free_all_locked
(
&
p
->
mwf
);
p_close
(
p
->
mwf
.
fd
);
}
pack_index_free
(
p
);
...
...
src/tree.c
View file @
86cb34cb
...
...
@@ -466,6 +466,7 @@ static int append_entry(
git_strmap_insert
(
bld
->
map
,
entry
->
filename
,
entry
,
error
);
if
(
error
<
0
)
{
git_tree_entry_free
(
entry
);
giterr_set
(
GITERR_TREE
,
"failed to append entry %s to the tree builder"
,
filename
);
return
-
1
;
}
...
...
@@ -622,6 +623,7 @@ int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source)
GITERR_CHECK_ALLOC
(
bld
);
if
(
git_strmap_alloc
(
&
bld
->
map
)
<
0
)
{
git__free
(
bld
);
return
-
1
;
}
...
...
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