Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Correctly free the list of keywords
Baptiste Daroussin committed 14 years ago
commit 3ccfb453db8727af4ac0f47e48e1beb22044305f
parent 7473489
3 files changed +27 -8
modified libpkg/pkg.c
@@ -806,14 +806,6 @@ pkg_list_is_empty(struct pkg *pkg, pkg_list list) {
	return (0);
}

-
#define LIST_FREE(head, data, free_func) do { \
-
	while (!STAILQ_EMPTY(head)) { \
-
		data = STAILQ_FIRST(head); \
-
		STAILQ_REMOVE_HEAD(head, next); \
-
		free_func(data); \
-
	}  \
-
	} while (0)
-

void
pkg_list_free(struct pkg *pkg, pkg_list list)  {
	struct pkg_dep *d;
modified libpkg/pkg_ports.c
@@ -244,6 +244,24 @@ populate_keywords(struct plist *p)

}

+
static void
+
keyword_free(struct keyword *k)
+
{
+
	struct action *a;
+

+
	LIST_FREE(&k->actions, a, free);
+

+
	free(k);
+
}
+

+
static void
+
plist_free(struct plist *plist)
+
{
+
	struct keyword *k;
+
	LIST_FREE(&plist->keywords, k, keyword_free);
+
	return;
+
}
+

static int
parse_keywords(struct plist *plist, char *keyword, char *line)
{
@@ -525,6 +543,7 @@ ports_parse_plist(struct pkg *pkg, char *plist)
	free(hardlinks.inodes);

	free(plist_buf);
+
	plist_free(&pplist);

	return (ret);
}
modified libpkg/pkg_private.h
@@ -19,6 +19,14 @@
		ARCHIVE_EXTRACT_TIME  |ARCHIVE_EXTRACT_ACL | \
		ARCHIVE_EXTRACT_FFLAGS|ARCHIVE_EXTRACT_XATTR)

+
#define LIST_FREE(head, data, free_func) do { \
+
	while (!STAILQ_EMPTY(head)) { \
+
		data = STAILQ_FIRST(head); \
+
		STAILQ_REMOVE_HEAD(head, next); \
+
		free_func(data); \
+
	}  \
+
	} while (0)
+

struct pkg {
	struct sbuf * fields[PKG_NUM_FIELDS];
	bool automatic;