summaryrefslogtreecommitdiff
path: root/src/index.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/index.c
parent069c89898478b0273f7e6d0ea803d6151ee74ff7 (diff)
downloadapk-tools-7be853e63785276338a4c4d9e5be084f24114bed.tar.gz
apk-tools-7be853e63785276338a4c4d9e5be084f24114bed.tar.bz2
apk-tools-7be853e63785276338a4c4d9e5be084f24114bed.tar.xz
apk-tools-7be853e63785276338a4c4d9e5be084f24114bed.zip
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/index.c')
-rw-r--r--src/index.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/index.c b/src/index.c
index fffa739..2676269 100644
--- a/src/index.c
+++ b/src/index.c
@@ -72,7 +72,7 @@ static int warn_if_no_providers(apk_hash_item item, void *ctx)
struct counts *counts = (struct counts *) ctx;
struct apk_name *name = (struct apk_name *) item;
- if (name->pkgs == NULL) {
+ if (name->pkgs->num == 0) {
if (++counts->unsatisfied < 10) {
apk_warning("No provider for dependency '%s'",
name->name);
@@ -139,7 +139,7 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv)
/* If we have it in the old index already? */
name = apk_db_query_name(db, bname);
- if (name == NULL || name->pkgs == NULL)
+ if (name == NULL)
break;
for (j = 0; j < name->pkgs->num; j++) {