'\" t .\" Copyright 1993, David Metcalfe .\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .TH strdupa 3 2026-02-25 "Linux man-pages 6.18" .SH NAME strdupa, strndupa \- string duplicate using alloca .SH LIBRARY Standard C library .RI ( libc ,\~ \-lc ) .SH SYNOPSIS .nf .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .B #include .P .BI "char *strdupa(const char *" s ); .BR "char *strndupa(" "size_t n;" .BI " const char " s [ n "], size_t " n ); .fi .SH DESCRIPTION .TP .BR strdupa () .BR strdupa () is similar to .BR strdup (3), but uses .BR alloca (3) to allocate the buffer. .IP It is equivalent to .IP .in +4n .EX strcpy(alloca(strlen(s) + 1), s) .EE .in .TP .BR strndupa () .BR strndupa () is similar to .BR strndupa (3), but uses .BR alloca (3) to allocate the buffer. .IP It is equivalent to .IP .in +4n .EX strncat(strcpy(alloca(n + 1), ""), s, n) .EE .in .SH RETURN VALUE On success, these macros return 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 strdupa (), .BR strndupa () T} Thread safety MT-Safe .TE .SH STANDARDS GNU. .SH HISTORY GNU. .SH SEE ALSO .BR alloca (3), .BR strdup (3), .BR strndup (3)