Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
change pkg_open behaviour: Now if the second arguments points to an already existing struct pkg * then is will be reused this can save lots of allocation and time
Baptiste Daroussin committed 15 years ago
commit 7f4f9b397ab4280d679bc8c3d3cbbca854128f3b
parent a339f09
2 files changed +8 -3
modified libpkg/pkg.c
@@ -202,7 +202,11 @@ pkg_open(const char *path, struct pkg **pkg_p, int query_flags)
	archive_read_support_compression_all(a);
	archive_read_support_format_tar(a);

-
	pkg_new(pkg_p);
+
	if (*pkg_p == NULL)
+
		pkg_new(pkg_p);
+
	else
+
		pkg_reset(*pkg_p);
+

	pkg = *pkg_p;
	pkg->type = PKG_FILE;

modified libpkg/pkg_repo.c
@@ -18,7 +18,8 @@ pkg_create_repo(char *path, void (progress)(struct pkg *pkg, void *data), void *
	FTSENT	*ent;

	struct stat st;
-
	struct pkg *pkg, **deps;
+
	struct pkg *pkg = NULL;
+
	struct pkg **deps;
	struct pkg_file **files;
	char *ext = NULL;
	sqlite3 *sqlite;
@@ -141,9 +142,9 @@ pkg_create_repo(char *path, void (progress)(struct pkg *pkg, void *data), void *
			}
		}

-
		pkg_free(pkg);
	}
	fts_close(fts);
+
	pkg_free(pkg);

	sqlite3_finalize(stmt_pkg);
	sqlite3_finalize(stmt_deps);