diff options
author | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-15 00:18:11 (EST) |
---|---|---|
committer | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-15 00:18:11 (EST) |
commit | 90299e3df5c5d5eb4ae2189b11e44ec83995ca62 (patch) | |
tree | a405f8b82e3b9514d9397698bba73742dfc4ede6 /libopkg/pkg_hash.c | |
parent | ddd373d69aac313269e6465a83c633d9a1815643 (diff) |
opkg: (leak fixing, day 1) lots and lots of memory leaks fixed
git-svn-id: http://opkg.googlecode.com/svn/trunk@114 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/pkg_hash.c')
-rw-r--r-- | libopkg/pkg_hash.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index b293195..580fe6e 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -53,8 +53,34 @@ int pkg_hash_init(const char *name, hash_table_t *hash, int len) return hash_table_init(name, hash, len); } +void free_pkgs (const char *key, void *entry, void *data) +{ + int i; + abstract_pkg_t *ab_pkg; + + /* each entry in the hash table is an abstract package, which contains a list + * of packages that provide the abstract package */ + + ab_pkg = (abstract_pkg_t*) entry; + + if (ab_pkg->pkgs) + { + for (i = 0; i < ab_pkg->pkgs->len; i++) + { + pkg_deinit (ab_pkg->pkgs->pkgs[i]); + free (ab_pkg->pkgs->pkgs[i]); + } + } + + abstract_pkg_vec_free (ab_pkg->provided_by); + pkg_vec_free (ab_pkg->pkgs); + free (ab_pkg->name); + free (ab_pkg); +} + void pkg_hash_deinit(hash_table_t *hash) { + hash_table_foreach (hash, free_pkgs, NULL); hash_table_deinit(hash); } |