Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
apk-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hassan Albahri
apk-tools
Commits
0314104d
Commit
0314104d
authored
16 years ago
by
Timo Teräs
Browse files
Options
Downloads
Patches
Plain Diff
db, pkg: fix rest of memory leaks
parent
5e2aca26
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/database.c
+35
-0
35 additions, 0 deletions
src/database.c
src/hash.c
+1
-1
1 addition, 1 deletion
src/hash.c
src/package.c
+2
-0
2 additions, 0 deletions
src/package.c
with
38 additions
and
1 deletion
src/database.c
+
35
−
0
View file @
0314104d
...
...
@@ -102,6 +102,7 @@ struct apk_name *apk_db_get_name(struct apk_database *db, apk_blob_t name)
void
apk_name_free
(
struct
apk_name
*
name
)
{
free
(
name
->
name
);
free
(
name
->
pkgs
);
free
(
name
);
}
...
...
@@ -197,6 +198,13 @@ static void apk_db_diri_create(struct apk_db_dir_instance *diri)
}
}
static
void
apk_db_diri_free
(
struct
apk_database
*
db
,
struct
apk_db_dir_instance
*
diri
)
{
apk_db_dir_put
(
db
,
diri
->
dir
);
free
(
diri
);
}
static
struct
apk_db_file
*
apk_db_file_new
(
struct
apk_db_dir
*
dir
,
apk_blob_t
name
,
struct
hlist_node
**
after
)
...
...
@@ -249,6 +257,11 @@ static struct apk_db_file *apk_db_file_get(struct apk_database *db,
return
file
;
}
static
void
apk_db_file_free
(
struct
apk_db_file
*
file
)
{
free
(
file
);
}
static
struct
apk_package
*
apk_db_pkg_add
(
struct
apk_database
*
db
,
struct
apk_package
*
pkg
)
{
struct
apk_package
*
idb
;
...
...
@@ -623,6 +636,28 @@ static int apk_db_write_config(struct apk_database *db)
void
apk_db_close
(
struct
apk_database
*
db
)
{
struct
apk_package
*
pkg
;
struct
apk_db_dir_instance
*
diri
;
struct
apk_db_file
*
file
;
struct
hlist_node
*
dc
,
*
dn
,
*
fc
,
*
fn
;
int
i
;
list_for_each_entry
(
pkg
,
&
db
->
installed
.
packages
,
installed_pkgs_list
)
{
hlist_for_each_entry_safe
(
diri
,
dc
,
dn
,
&
pkg
->
owned_dirs
,
pkg_dirs_list
)
{
hlist_for_each_entry_safe
(
file
,
fc
,
fn
,
&
diri
->
owned_files
,
diri_files_list
)
apk_db_file_free
(
file
);
apk_db_diri_free
(
db
,
diri
);
}
}
for
(
i
=
0
;
i
<
db
->
num_repos
;
i
++
)
free
(
db
->
repos
[
i
].
url
);
for
(
i
=
0
;
i
<
db
->
protected_paths
->
num
;
i
++
)
free
(
db
->
protected_paths
->
item
[
i
]);
free
(
db
->
protected_paths
);
free
(
db
->
world
);
apk_hash_free
(
&
db
->
available
.
names
);
apk_hash_free
(
&
db
->
available
.
packages
);
apk_hash_free
(
&
db
->
installed
.
dirs
);
...
...
This diff is collapsed.
Click to expand it.
src/hash.c
+
1
−
1
View file @
0314104d
...
...
@@ -35,7 +35,7 @@ int apk_hash_foreach(struct apk_hash *h, apk_hash_enumerator_f e, void *ctx)
for
(
i
=
0
;
i
<
h
->
buckets
->
num
;
i
++
)
{
hlist_for_each_safe
(
pos
,
n
,
&
h
->
buckets
->
item
[
i
])
{
r
=
e
(((
void
*
)
pos
)
-
offset
,
ctx
);
if
(
r
!=
0
)
if
(
r
!=
0
&&
ctx
!=
NULL
)
return
r
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/package.c
+
2
−
0
View file @
0314104d
...
...
@@ -380,6 +380,8 @@ void apk_pkg_free(struct apk_package *pkg)
hlist_for_each_entry_safe
(
script
,
c
,
n
,
&
pkg
->
scripts
,
script_list
)
free
(
script
);
if
(
pkg
->
depends
)
free
(
pkg
->
depends
);
if
(
pkg
->
version
)
free
(
pkg
->
version
);
if
(
pkg
->
url
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment