From 9227a343bdf7096debb3b5016c6c2830ade06402 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sun, 19 Jan 2025 15:32:12 +0100 Subject: [PATCH] lib/string/strdup/strndupa.h: STRNDUPA(): Simplify implementation Signed-off-by: Alejandro Colomar --- lib/string/strdup/strndupa.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/string/strdup/strndupa.h b/lib/string/strdup/strndupa.h index cc62204a77..5e2de460d3 100644 --- a/lib/string/strdup/strndupa.h +++ b/lib/string/strdup/strndupa.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar // SPDX-License-Identifier: BSD-3-Clause @@ -12,7 +12,6 @@ #include #include "sizeof.h" -#include "string/strcpy/strncat.h" #ifndef strndupa @@ -20,11 +19,8 @@ #endif -// Similar to strndupa(3), but ensure that 's' is an array. -#define STRNDUPA(s) \ -( \ - STRNCAT(strcpy(alloca(strnlen(s, NITEMS(s)) + 1), ""), s) \ -) +// strndupa(3), but ensure that 's' is an array. +#define STRNDUPA(s) strndupa(s, NITEMS(s)) #endif // include guard