Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
array_append always set n+1 to NULL.
jlaffaye committed 15 years ago
commit 71c3867563b16a1d8cf746d6bd0fa5bc00ce3ff0
parent 8042cb4e0c658c1bd406404772bbaf3d49651596
2 files changed +4 -10
modified libpkg/pkgdb.c
@@ -225,8 +225,6 @@ pkgdb_it_next_pkg(struct pkgdb_it *it, struct pkg **pkg_p, int flags)
				p = NULL;
			}
			pkgdb_it_free(i);
-

-
			array_append(&pkg->deps, NULL);
		}

		if (flags & PKG_RDEPS) {
@@ -239,8 +237,6 @@ pkgdb_it_next_pkg(struct pkgdb_it *it, struct pkg **pkg_p, int flags)
				p = NULL;
			}
			pkgdb_it_free(i);
-

-
			array_append(&pkg->rdeps, NULL);
		}

		if (flags & PKG_CONFLICTS) {
@@ -253,8 +249,6 @@ pkgdb_it_next_pkg(struct pkgdb_it *it, struct pkg **pkg_p, int flags)
				c = NULL;
			}
			pkgdb_it_free(i);
-

-
			array_append(&pkg->conflicts, NULL);
		}

		if (flags & PKG_FILES) {
@@ -267,8 +261,6 @@ pkgdb_it_next_pkg(struct pkgdb_it *it, struct pkg **pkg_p, int flags)
				f = NULL;
			}
			pkgdb_it_free(i);
-

-
			array_append(&pkg->files, NULL);
		}
		return (0);
	case SQLITE_DONE:
modified libpkg/util.c
@@ -34,11 +34,13 @@ array_append(struct array *a, void *d)
	assert(a->cap > 0);
	assert(a->data != NULL);

-
	if (a->cap <= a->len) {
+
	if (a->cap <= a->len + 1) {
		a->cap *= 2;
		a->data = realloc(a->data, sizeof(void*) * a->cap);
	}
-
	a->data[a->len++] = d;
+
	a->len++;
+
	a->data[a->len] = d;
+
	a->data[a->len+1] = NULL;
}

void