From 7be853e63785276338a4c4d9e5be084f24114bed Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Sat, 5 Jun 2010 12:06:41 +0300 Subject: 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. --- src/search.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/search.c') diff --git a/src/search.c b/src/search.c index e5e5d55..14eb0fb 100644 --- a/src/search.c +++ b/src/search.c @@ -45,18 +45,12 @@ static int print_rdepends(struct apk_package *pkg) int i, j, k; name = pkg->name; - if (name->rdepends == NULL) - return 0; printf("%s-%s:", pkg->name->name, pkg->version); for (i = 0; i < name->rdepends->num; i++) { name0 = name->rdepends->item[i]; - if (name0->pkgs == NULL) - continue; for (j = 0; j < name0->pkgs->num; j++) { pkg0 = name0->pkgs->item[j]; - if (pkg0->depends == NULL) - continue; for (k = 0; k < pkg0->depends->num; k++) { dep = &pkg0->depends->item[k]; if (name == dep->name && @@ -146,7 +140,7 @@ static int search_main(void *ctx, struct apk_database *db, int argc, char **argv } else { for (i = 0; i < argc; i++) { name = apk_db_query_name(db, APK_BLOB_STR(argv[i])); - if (name == NULL || name->pkgs == NULL) + if (name == NULL) continue; for (j = 0; j < name->pkgs->num; j++) ictx->print(name->pkgs->item[j]); -- cgit v1.2.3-60-g2f50