From: djm@openbsd.org Date: Thu, 6 Nov 2025 01:31:11 +0000 (+0000) Subject: upstream: move stringlist_append() and stringlist_free() to misc.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1399419f0b2d024bde968ffe769a3808611917e4;p=thirdparty%2Fopenssh-portable.git upstream: move stringlist_append() and stringlist_free() to misc.c OpenBSD-Commit-ID: 7d047bbff6964b9abbc04e9b3e2e1b4cc1db0aea --- diff --git a/misc.c b/misc.c index ce77ec943..15d7fc4df 100644 --- a/misc.c +++ b/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.208 2025/09/25 06:33:19 djm Exp $ */ +/* $OpenBSD: misc.c,v 1.209 2025/11/06 01:31:11 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005-2020 Damien Miller. All rights reserved. @@ -121,6 +121,34 @@ strprefix(const char *s, const char *prefix, int ignorecase) return s + prefixlen; } +/* Append string 's' to a NULL-terminated array of strings */ +void +stringlist_append(char ***listp, const char *s) +{ + size_t i = 0; + + if (*listp == NULL) + *listp = xcalloc(2, sizeof(**listp)); + else { + for (i = 0; (*listp)[i] != NULL; i++) + ; /* count */ + *listp = xrecallocarray(*listp, i + 1, i + 2, sizeof(**listp)); + } + (*listp)[i] = xstrdup(s); +} + +void +stringlist_free(char **list) +{ + size_t i = 0; + + if (list == NULL) + return; + for (i = 0; list[i] != NULL; i++) + free(list[i]); + free(list); +} + /* set/unset filedescriptor to non-blocking */ int set_nonblock(int fd) diff --git a/misc.h b/misc.h index f3c5a18c6..f106be18f 100644 --- a/misc.h +++ b/misc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.h,v 1.112 2025/09/25 06:33:19 djm Exp $ */ +/* $OpenBSD: misc.h,v 1.113 2025/11/06 01:31:11 djm Exp $ */ /* * Author: Tatu Ylonen @@ -59,6 +59,8 @@ void skip_space(char **); const char *strprefix(const char *, const char *, int); char *strdelim(char **); char *strdelimw(char **); +void stringlist_append(char ***listp, const char *s); +void stringlist_free(char **list); int set_nonblock(int); int unset_nonblock(int); void set_nodelay(int); diff --git a/ssh-add.c b/ssh-add.c index 2d5bec89c..412635b29 100644 --- a/ssh-add.c +++ b/ssh-add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-add.c,v 1.181 2025/09/29 03:17:54 djm Exp $ */ +/* $OpenBSD: ssh-add.c,v 1.182 2025/11/06 01:31:11 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -649,34 +649,6 @@ do_file(int agent_fd, int deleting, int key_only, int cert_only, return 0; } -/* Append string 's' to a NULL-terminated array of strings */ -static void -stringlist_append(char ***listp, const char *s) -{ - size_t i = 0; - - if (*listp == NULL) - *listp = xcalloc(2, sizeof(**listp)); - else { - for (i = 0; (*listp)[i] != NULL; i++) - ; /* count */ - *listp = xrecallocarray(*listp, i + 1, i + 2, sizeof(**listp)); - } - (*listp)[i] = xstrdup(s); -} - -static void -stringlist_free(char **list) -{ - size_t i = 0; - - if (list == NULL) - return; - for (i = 0; list[i] != NULL; i++) - free(list[i]); - free(list); -} - static void free_dest_constraint_hop(struct dest_constraint_hop *dch) {