Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Prefer double linked list when appending data
Baptiste Daroussin committed 9 years ago
commit bf4c2001cd48a5485ab5bea17c6200ba02efaee2
parent 268ded2
8 files changed +34 -35
modified libpkg/fetch.c
@@ -521,9 +521,9 @@ pkg_fetch_file_to_fd(struct pkg_repo *repo, const char *url, int dest,
			kvtmp->key = xstrdup(kv->key);
			if ((tmp = getenv(kv->key)) != NULL) {
				kvtmp->value = xstrdup(tmp);
-
				LL_APPEND(envtorestore, kvtmp);
+
				DL_APPEND(envtorestore, kvtmp);
			} else {
-
				LL_APPEND(envtounset, kvtmp);
+
				DL_APPEND(envtounset, kvtmp);
			}
			setenv(kv->key, kv->value, 1);
		}
modified libpkg/pkg.c
@@ -103,8 +103,8 @@ pkg_free(struct pkg *pkg)
	pkg_list_free(pkg, PKG_CATEGORIES);
	pkg_list_free(pkg, PKG_LICENSES);

-
	LL_FREE(pkg->message, pkg_message_free);
-
	LL_FREE(pkg->annotations, pkg_kv_free);
+
	DL_FREE(pkg->message, pkg_message_free);
+
	DL_FREE(pkg->annotations, pkg_kv_free);

	if (pkg->rootfd != -1)
		close(pkg->rootfd);
@@ -731,7 +731,7 @@ pkg_addfile_attr(struct pkg *pkg, const char *path, const char *sum,
		f->fflags = fflags;

	kh_safe_add(pkg_files, pkg->filehash, f, f->path);
-
	LL_APPEND(pkg->files, f);
+
	DL_APPEND(pkg->files, f);

	return (EPKG_OK);
}
@@ -838,7 +838,7 @@ pkg_adddir_attr(struct pkg *pkg, const char *path, const char *uname,
		d->fflags = fflags;

	kh_safe_add(pkg_dirs, pkg->dirhash, d, d->path);
-
	LL_APPEND(pkg->dirs, d);
+
	DL_APPEND(pkg->dirs, d);

	return (EPKG_OK);
}
@@ -1013,7 +1013,7 @@ pkg_addoption(struct pkg *pkg, const char *key, const char *value)
	o->key = xstrdup(key);
	o->value = xstrdup(value);
	kh_safe_add(pkg_options, pkg->optionshash, o, o->key);
-
	LL_APPEND(pkg->options, o);
+
	DL_APPEND(pkg->options, o);

	return (EPKG_OK);
}
@@ -1047,7 +1047,7 @@ pkg_addoption_default(struct pkg *pkg, const char *key,
	o->key = xstrdup(key);
	o->default_value = xstrdup(default_value);
	kh_safe_add(pkg_options, pkg->optionshash, o, o->key);
-
	LL_APPEND(pkg->options, o);
+
	DL_APPEND(pkg->options, o);

	return (EPKG_OK);
}
@@ -1081,7 +1081,7 @@ pkg_addoption_description(struct pkg *pkg, const char *key,
	o->key = xstrdup(key);
	o->description = xstrdup(description);
	kh_safe_add(pkg_options, pkg->optionshash, o, o->key);
-
	LL_APPEND(pkg->options, o);
+
	DL_APPEND(pkg->options, o);

	return (EPKG_OK);
}
@@ -1148,7 +1148,7 @@ pkg_addconflict(struct pkg *pkg, const char *uniqueid)
	pkg_debug(3, "Pkg: add a new conflict origin: %s, with %s", pkg->uid, uniqueid);

	kh_safe_add(pkg_conflicts, pkg->conflictshash, c, c->uid);
-
	LL_APPEND(pkg->conflicts, c);
+
	DL_APPEND(pkg->conflicts, c);

	return (EPKG_OK);
}
@@ -1229,7 +1229,7 @@ pkg_kv_add(struct pkg_kv **list, const char *key, const char *val, const char *t
	}

	kv = pkg_kv_new(key, val);
-
	LL_APPEND(*list, kv);
+
	DL_APPEND(*list, kv);

	return (EPKG_OK);
}
@@ -1294,19 +1294,19 @@ pkg_list_free(struct pkg *pkg, pkg_list list) {
		pkg->flags &= ~PKG_LOAD_RDEPS;
		break;
	case PKG_OPTIONS:
-
		LL_FREE(pkg->options, pkg_option_free);
+
		DL_FREE(pkg->options, pkg_option_free);
		kh_destroy_pkg_options(pkg->optionshash);
		pkg->flags &= ~PKG_LOAD_OPTIONS;
		break;
	case PKG_FILES:
	case PKG_CONFIG_FILES:
-
		LL_FREE(pkg->files, pkg_file_free);
+
		DL_FREE(pkg->files, pkg_file_free);
		kh_destroy_pkg_files(pkg->filehash);
		kh_free(pkg_config_files, pkg->config_files, struct pkg_config_file, pkg_config_file_free);
		pkg->flags &= ~PKG_LOAD_FILES;
		break;
	case PKG_DIRS:
-
		LL_FREE(pkg->dirs, free);
+
		DL_FREE(pkg->dirs, free);
		kh_destroy_pkg_dirs(pkg->dirhash);
		pkg->flags &= ~PKG_LOAD_DIRS;
		break;
@@ -1327,7 +1327,7 @@ pkg_list_free(struct pkg *pkg, pkg_list list) {
		pkg->flags &= ~PKG_LOAD_SHLIBS_PROVIDED;
		break;
	case PKG_CONFLICTS:
-
		LL_FREE(pkg->conflicts, pkg_conflict_free);
+
		DL_FREE(pkg->conflicts, pkg_conflict_free);
		kh_destroy_pkg_conflicts(pkg->conflictshash);
		pkg->flags &= ~PKG_LOAD_CONFLICTS;
		break;
@@ -1774,7 +1774,7 @@ pkg_message_from_ucl(struct pkg *pkg, const ucl_object_t *obj)
		msg = xcalloc(1, sizeof(*msg));
		msg->str = xstrdup(ucl_object_tostring(obj));
		msg->type = PKG_MESSAGE_ALWAYS;
-
		LL_APPEND(pkg->message, msg);
+
		DL_APPEND(pkg->message, msg);
		return (EPKG_OK);
	}

@@ -1810,7 +1810,7 @@ pkg_message_from_ucl(struct pkg *pkg, const ucl_object_t *obj)
				    " message will always be printed");
		}
		if (msg->type != PKG_MESSAGE_UPGRADE) {
-
			LL_APPEND(pkg->message, msg);
+
			DL_APPEND(pkg->message, msg);
			continue;
		}

@@ -1824,7 +1824,7 @@ pkg_message_from_ucl(struct pkg *pkg, const ucl_object_t *obj)
			msg->maximum_version = xstrdup(ucl_object_tostring(elt));
		}

-
		LL_APPEND(pkg->message, msg);
+
		DL_APPEND(pkg->message, msg);
	}

	return (EPKG_OK);
modified libpkg/pkg.h.in
@@ -118,7 +118,7 @@ typedef void * pkg_iter;
struct pkg_kv {
	char *key;
	char *value;
-
	struct pkg_kv *next;
+
	struct pkg_kv *next, *prev;
};

/**
modified libpkg/pkg_config.c
@@ -689,7 +689,7 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
		while ((cur = ucl_iterate_object(env, &it, true))) {
			kv = pkg_kv_new(ucl_object_key(cur),
			    ucl_object_tostring_forced(cur));
-
			LL_APPEND(r->env, kv);
+
			DL_APPEND(r->env, kv);
		}
	}
}
modified libpkg/pkg_jobs_conflicts.c
@@ -171,7 +171,7 @@ pkg_conflicts_register(struct pkg *p1, struct pkg *p2, enum pkg_conflict_type ty
	if (!kh_contains(pkg_conflicts, p1->conflictshash, p2->uid)) {
		c1->uid = xstrdup(p2->uid);
		kh_safe_add(pkg_conflicts, p1->conflictshash, c1, c1->uid);
-
		LL_APPEND(p1->conflicts, c1);
+
		DL_APPEND(p1->conflicts, c1);
		pkg_debug(2, "registering conflict between %s(%s) and %s(%s)",
				p1->uid, p1->type == PKG_INSTALLED ? "l" : "r",
				p2->uid, p2->type == PKG_INSTALLED ? "l" : "r");
@@ -182,7 +182,7 @@ pkg_conflicts_register(struct pkg *p1, struct pkg *p2, enum pkg_conflict_type ty
	if (!kh_contains(pkg_conflicts, p2->conflictshash, p1->uid)) {
		c2->uid = xstrdup(p1->uid);
		kh_safe_add(pkg_conflicts, p2->conflictshash, c2, c2->uid);
-
		LL_APPEND(p2->conflicts, c2);
+
		DL_APPEND(p2->conflicts, c2);
		pkg_debug(2, "registering conflict between %s(%s) and %s(%s)",
				p2->uid, p2->type == PKG_INSTALLED ? "l" : "r",
				p1->uid, p1->type == PKG_INSTALLED ? "l" : "r");
@@ -266,7 +266,7 @@ pkg_conflicts_register_unsafe(struct pkg *p1, struct pkg *p2,
		}

		kh_safe_add(pkg_conflicts, p1->conflictshash, c1, c1->uid);
-
		LL_APPEND(p1->conflicts, c1);
+
		DL_APPEND(p1->conflicts, c1);
	}

	if (c2 == NULL) {
@@ -282,7 +282,7 @@ pkg_conflicts_register_unsafe(struct pkg *p1, struct pkg *p2,
		}

		kh_safe_add(pkg_conflicts, p2->conflictshash, c2, c2->uid);
-
		LL_APPEND(p2->conflicts, c2);
+
		DL_APPEND(p2->conflicts, c2);
	}

	pkg_debug(2, "registering conflict between %s(%s) and %s(%s) on path %s",
modified libpkg/pkg_ports.c
@@ -740,7 +740,7 @@ populate_keywords(struct plist *p)
		a = xmalloc(sizeof(struct action));
		strlcpy(k->keyword, keyacts[i].key, sizeof(k->keyword));
		a->perform = keyacts[i].action;
-
		LL_APPEND(k->actions, a);
+
		DL_APPEND(k->actions, a);
		HASH_ADD_STR(p->keywords, keyword, k);
	}
}
@@ -748,8 +748,7 @@ populate_keywords(struct plist *p)
static void
keyword_free(struct keyword *k)
{
-
	LL_FREE(k->actions, free);
-

+
	DL_FREE(k->actions, free);
	free(k);
}

@@ -924,7 +923,7 @@ apply_keyword_file(ucl_object_t *obj, struct plist *p, char *line, struct file_a
				else if (strcasecmp(ucl_object_tostring(elt), "upgrade") == 0)
					msg->type = PKG_MESSAGE_UPGRADE;
			}
-
			LL_APPEND(p->pkg->message, msg);
+
			DL_APPEND(p->pkg->message, msg);
		}
	}

modified libpkg/pkg_repo_create.c
@@ -738,7 +738,7 @@ pkg_create_repo(char *path, const char *output_dir, bool filelist,
	}
cleanup:
	HASH_ITER (hh, conflicts, curcb, tmpcb) {
-
		LL_FREE(curcb->conflicts, pkg_conflict_free);
+
		DL_FREE(curcb->conflicts, pkg_conflict_free);
		kh_destroy_pkg_conflicts(curcb->conflictshash);
		HASH_DEL(conflicts, curcb);
		free(curcb);
modified libpkg/private/pkg.h
@@ -336,7 +336,7 @@ struct pkg_message {
	char			*minimum_version;
	char			*maximum_version;
	pkg_message_t		 type;
-
	struct pkg_message	*next;
+
	struct pkg_message	*next, *prev;
};

enum pkg_conflict_type {
@@ -350,7 +350,7 @@ struct pkg_conflict {
	char *uid;
	char *digest;
	enum pkg_conflict_type type;
-
	struct pkg_conflict *next;
+
	struct pkg_conflict *next, *prev;
};

typedef enum {
@@ -379,7 +379,7 @@ struct pkg_file {
	u_long		 fflags;
	struct pkg_config_file *config;
	struct timespec	 time[2];
-
	struct pkg_file	*next;
+
	struct pkg_file	*next, *prev;
};

struct pkg_dir {
@@ -392,7 +392,7 @@ struct pkg_dir {
	gid_t		 gid;
	bool		 noattrs;
	struct timespec	 time[2];
-
	struct pkg_dir	*next;
+
	struct pkg_dir	*next, *prev;
};

struct pkg_option {
@@ -400,7 +400,7 @@ struct pkg_option {
	char	*value;
	char	*default_value;
	char	*description;
-
	struct pkg_option *next;
+
	struct pkg_option *next, *prev;
};

struct http_mirror {
@@ -595,7 +595,7 @@ struct file_attr {

struct action {
	int (*perform)(struct plist *, char *, struct file_attr *);
-
	struct action *next;
+
	struct action *next, *prev;
};

/* sql helpers */