Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Rework add_request utility.
Vsevolod Stakhov committed 11 years ago
commit 706851276424ca852c12ff7e12fdd010f310fabe
parent a8c6aa2
2 files changed +18 -22
modified libpkg/pkg_jobs.c
@@ -250,36 +250,38 @@ pkg_jobs_iter(struct pkg_jobs *jobs, void **iter,
}

void
-
pkg_jobs_add_req(struct pkg_jobs *j, const char *uid,
-
		struct pkg_job_universe_item *item)
+
pkg_jobs_add_req(struct pkg_jobs *j, struct pkg *pkg)
{
-
	struct pkg_job_request *req, *test, **head;
+
	struct pkg_job_request *req, *head;
+
	struct pkg_job_request_item *nit;
+
	const char *uid;

-
	assert(item);
-
	assert(item->pkg);
+
	assert(pkg != NULL);

	if (!IS_DELETE(j)) {
		head = &j->request_add;
-
		assert(item->pkg->type != PKG_INSTALLED);
+
		assert(pkg->type != PKG_INSTALLED);
	}
	else {
		head = &j->request_delete;
-
		assert(item->pkg->type == PKG_INSTALLED);
+
		assert(pkg->type == PKG_INSTALLED);
	}

-
	HASH_FIND_PTR(*head, &item, test);
-

-
	if (test != NULL)
-
		return;
+
	pkg_get(pkg, PKG_UNIQUEID, &uid);
+
	HASH_FIND_STR(*head, uid, req);

-
	req = calloc(1, sizeof (struct pkg_job_request));
	if (req == NULL) {
-
		pkg_emit_errno("malloc", "struct pkg_job_request");
-
		return;
+
		/* Allocate new unique request item */
+
		req = calloc(1, sizeof (struct pkg_job_request));
+
		if (req == NULL) {
+
			pkg_emit_errno("malloc", "struct pkg_job_request");
+
			return;
+
		}
+
		req->item = item;
+
		HASH_ADD_KEYPTR(hh, *head, uid, strlen(uid), req);
	}
-
	req->item = item;

-
	HASH_ADD_PTR(*head, item, req);
+

}

static int
modified libpkg/private/pkg_jobs.h
@@ -162,12 +162,6 @@ int pkg_jobs_universe_process_item(struct pkg_jobs_universe *universe,
	struct pkg *pkg, struct pkg_job_universe_item **result);

/*
-
 * Add a universe item with package to the request
-
 */
-
void pkg_jobs_add_req(struct pkg_jobs *j, const char *uid,
-
	struct pkg_job_universe_item *item);
-

-
/*
 * Check if the specified digest was seen in the universe
 */
struct pkg_job_seen* pkg_jobs_universe_seen(struct pkg_jobs_universe *universe,