Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
refacto: convert actions_t to vector
Baptiste Daroussin committed 1 year ago
commit 9c8458420227cc8c85209027213133800256a681
parent e962753
4 files changed +5 -7
modified libpkg/pkg_add.c
@@ -26,7 +26,6 @@
#include <sys/wait.h>
#include <time.h>
#include <xstring.h>
-
#include <tllist.h>

#include "pkg.h"
#include "private/event.h"
modified libpkg/pkg_ports.c
@@ -518,7 +518,7 @@ populate_keywords(struct plist *p)
		a = xmalloc(sizeof(struct action));
		k->keyword = xstrdup(keyacts[i].key);
		a->perform = keyacts[i].action;
-
		tll_push_back(k->actions, a);
+
		vec_push(&k->actions, a);
		pkghash_safe_add(p->keywords, k->keyword, k, NULL);
	}
}
@@ -527,7 +527,7 @@ static void
keyword_free(struct keyword *k)
{
	free(k->keyword);
-
	tll_free_and_free(k->actions, free);
+
	vec_free_and_free(&k->actions, free);
	free(k);
}

@@ -907,8 +907,8 @@ parse_keywords(struct plist *plist, char *keyword,

	k = pkghash_get_value(plist->keywords, keyword);
	if (k != NULL) {
-
		tll_foreach(k->actions, a) {
-
			ret = a->item->perform(plist, line, attr);
+
		vec_foreach(k->actions, i) {
+
			ret = k->actions.d[i]->perform(plist, line, attr);
			if (ret != EPKG_OK)
				break;
		}
modified libpkg/private/pkg.h
@@ -557,7 +557,7 @@ struct pkg_repo {
	struct pkg_repo *next, *prev;
};

-
typedef tll(struct action *) actions_t;
+
typedef vec_t(struct action *) actions_t;
struct keyword {
	char *keyword;
	actions_t actions;
modified libpkg/utils.c
@@ -59,7 +59,6 @@
#include "private/utils.h"
#include "private/pkg.h"
#include "xmalloc.h"
-
#include "tllist.h"

extern struct pkg_ctx ctx;