]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/string/strdup/strndupa.h: STRNDUPA(): Simplify implementation
authorAlejandro Colomar <alx@kernel.org>
Sun, 19 Jan 2025 14:32:12 +0000 (15:32 +0100)
committerSerge Hallyn <serge@hallyn.com>
Tue, 27 May 2025 01:21:08 +0000 (20:21 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/string/strdup/strndupa.h

index c8d53f30b2be10c9c9e96dba48f09431465fa795..80b8c3dcdbdebfbc3756fb2efa22e2a3e0e8bb59 100644 (file)
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org>
 // SPDX-License-Identifier: BSD-3-Clause
 
 
@@ -12,7 +12,6 @@
 #include <string.h>
 
 #include "sizeof.h"
-#include "string/strcpy/strncat.h"
 
 
 // string n-bounded-read duplicate using-alloca(3)
 #endif
 
 
-// Similar to strndupa(3), but ensure that 's' is an array.
-#define STRNDUPA(s)                                                           \
-(                                                                             \
-       STRNCAT(strcpy(alloca(strnlen(s, NITEMS(s)) + 1), ""), s)             \
-)
+#define STRNDUPA(s)  strndupa(s, NITEMS(s))
 
 
 #endif  // include guard