This name better reflects that it handles arrays, and doesn't shout.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
s/
strndupa(3)
Create a new string (in stack) from a [[gnu::nonstring]].
- STRNDUPA()
+ strndupa_a()
Like strndupa(3), but takes an array.
STRNDUP()
#include "sizeof.h"
-// string n-bounded-read duplicate using-alloca(3)
+// strndupa - nonstring duplicate-into-string using-alloca(3)
#ifndef strndupa
# define strndupa(s, n) strncat(strcpy(alloca(n + 1), ""), s, n)
#endif
-#define STRNDUPA(s) strndupa(s, countof(s))
+// strndupa_a - nonstring duplicate-into-string using-alloca(3) array
+#define strndupa_a(s) strndupa(s, countof(s))
#endif // include guard
char *line;
time_t now;
- user = STRNDUPA(ut->ut_user);
- line = STRNDUPA(ut->ut_line);
+ user = strndupa_a(ut->ut_user);
+ line = strndupa_a(ut->ut_line);
now = time(NULL);
SYSLOG ((LOG_NOTICE,
"logged off user '%s' on '%s'",
- STRNDUPA(ut->ut_user),
+ strndupa_a(ut->ut_user),
tty_name));
/*