summaryrefslogtreecommitdiffstats
path: root/src/cache.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-06-05 12:06:41 +0300
committerTimo Teräs <timo.teras@iki.fi>2010-06-05 12:33:54 +0300
commit7be853e63785276338a4c4d9e5be084f24114bed (patch)
tree3481293203a948897d7a10f9fb74f09a7c7d6286 /src/cache.c
parent069c89898478b0273f7e6d0ea803d6151ee74ff7 (diff)
downloadapk-tools-7be853e63785276338a4c4d9e5be084f24114bed.tar.bz2
apk-tools-7be853e63785276338a4c4d9e5be084f24114bed.tar.xz
all: rework how arrays work
Instead of having a null pointer, use a dummy array which just says the array is empty. This helps in multiple places of the code which would otherwise need explicitly need to check first if the array exists. This has been cause of multiple seg.faults in the past as the array check is easily omitted. This also removes (or fixes) all existing checks accordingly.
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/cache.c b/src/cache.c
index 85d9777..4ed89fa 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -32,9 +32,6 @@ static int cache_download(struct apk_database *db)
char item[PATH_MAX], cacheitem[PATH_MAX];
int i, r = 0;
- if (db->world == NULL)
- return 0;
-
state = apk_state_new(db);
if (state == NULL)
goto err;
@@ -111,7 +108,7 @@ static int cache_clean(struct apk_database *db)
} else {
/* Package - search for it */
name = apk_db_get_name(db, bname);
- if (name == NULL || name->pkgs == NULL)
+ if (name == NULL)
break;
for (i = 0; i < name->pkgs->num; i++) {
struct apk_package *pkg = name->pkgs->item[i];