Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
repo: replace tll with vector
Baptiste Daroussin committed 1 year ago
commit e7b72bf6604c5e8e8b20d2628a5dbdb1cca7be5b
parent 3c88d19
1 file changed +8 -27
modified libpkg/pkg_repo_create.c
@@ -1,5 +1,5 @@
/*-
-
 * Copyright (c) 2011-2024 Baptiste Daroussin <bapt@FreeBSD.org>
+
 * Copyright (c) 2011-2025 Baptiste Daroussin <bapt@FreeBSD.org>
 * Copyright (c) 2011-2012 Julien Laffaye <jlaffaye@FreeBSD.org>
 * Copyright (c) 2011-2012 Marin Atanasov Nikolov <dnaeon@gmail.com>
 * Copyright (c) 2012-2013 Matthew Seaman <matthew@FreeBSD.org>
@@ -7,27 +7,9 @@
 * Copyright (c) 2023-2024 Serenity Cyber Security, LLC
 *                         Author: Gleb Popov <arrowd@FreeBSD.org>
 *
-
 * Redistribution and use in source and binary forms, with or without
-
 * modification, are permitted provided that the following conditions
-
 * are met:
-
 * 1. Redistributions of source code must retain the above copyright
-
 *    notice, this list of conditions and the following disclaimer
-
 *    in this position and unchanged.
-
 * 2. Redistributions in binary form must reproduce the above copyright
-
 *    notice, this list of conditions and the following disclaimer in the
-
 *    documentation and/or other materials provided with the distribution.
-
 *
-
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
-
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
-
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 * SPDX-License-Identifier: BSD-2-Clause
 */
+

#include "pkg_config.h"

#include <sys/types.h>
@@ -52,7 +34,6 @@
#include <fcntl.h>
#include <dirent.h>

-
#include "tllist.h"
#include "pkg.h"
#include "private/event.h"
#include "private/utils.h"
@@ -156,7 +137,7 @@ struct pkg_fts_item {
	off_t fts_size;
	int fts_info;
};
-
typedef tll(struct pkg_fts_item *) fts_item_t;
+
typedef vec_t(struct pkg_fts_item *) fts_item_t;

static struct pkg_fts_item*
pkg_create_repo_fts_new(FTSENT *fts, const char *root_path)
@@ -289,7 +270,7 @@ pkg_create_repo_read_fts(fts_item_t *items, FTS *fts,
		if (fts_cur == NULL)
			return (EPKG_FATAL);

-
		tll_push_front(*items, fts_cur);
+
		vec_push(items, fts_cur);
		(*plen) ++;
	}

@@ -336,11 +317,11 @@ pkg_create_repo_thread(void *arg)
		if (items != NULL)
			pkg_create_repo_fts_free(items);
		pthread_mutex_lock(&te->llock);
-
		if (tll_length(te->fts_items) == 0) {
+
		if (te->fts_items.len == 0) {
			pthread_mutex_unlock(&te->llock);
			goto cleanup;
		}
-
		items = tll_pop_front(te->fts_items);
+
		items = vec_pop(&te->fts_items);
		pthread_mutex_unlock(&te->llock);
		path = items->fts_accpath;
		repopath = items->pkg_path;
@@ -950,7 +931,7 @@ cleanup:
	if (fts != NULL)
		fts_close(fts);

-
	tll_free_and_free(te.fts_items, pkg_create_repo_fts_free);
+
	vec_free_and_free(&te.fts_items, pkg_create_repo_fts_free);

	if (retcode != EPKG_OK)
		return (retcode);