'\" t .\" Copyright 1993, David Metcalfe .\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .TH strndupa 3 2026-08-17 "Linux man-pages 6.19" .SH NAME strndupa \- nonstring duplicate-into-string using-alloca .SH LIBRARY Standard C library .RI ( libc ,\~ \-lc ) .SH SYNOPSIS .nf .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .BR #include\~ " // see memory.h(3head)" .P .BR "char *strndupa(" "size_t n;" .BI " const char " strn [ n "], size_t " n ); .fi .SH DESCRIPTION .BR strndupa () is similar to .BR strndup (3), but uses .BR alloca (3) to allocate the buffer. .P It is equivalent to .P .in +4n .EX strncat(strcpy(alloca(n + 1), ""), strn, n) .EE .in .SH RETURN VALUE On success, this macro returns a pointer to the duplicated string. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). .TS allbox; lbx lb lb l l l. Interface Attribute Value T{ .na .nh .BR strndupa () T} Thread safety MT-Safe .TE .SH STANDARDS GNU. .SH HISTORY GNU. .SH SEE ALSO .BR memory.h (3head), .BR alloca (3), .BR strndup (3)