.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sun Jul 25 10:41:34 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Wed Oct 17 01:12:26 2001 by John Levon .\" Translated into Spanish Wed Mar 11 11:18:39 CET 1998 by Gerardo .\" Aburruzaga García .\" .TH STRDUP 3 "12 abril 1993" "GNU" "Manual del Programador de Linux" .SH NOMBRE strdup, strndup, strdupa, strndupa \- duplican una cadena de caracteres .SH SINOPSIS .nf .B #include .sp .BI "char *strdup(const char *" s ); .sp .B #define _GNU_SOURCE .br .B #include .sp .BI "char *strndup(const char *" s ", size_t " n ); .br .BI "char *strdupa(const char *" s ); .br .BI "char *strndupa(const char *" s ", size_t " n ); .sp .fi .SH DESCRIPCIÓN La función \fBstrdup()\fP devuelve un puntero a una nueva cadena de caracteres que es un duplicado de la cadena apuntada por \fIs\fP. La memoria para la nueva cadena se obtiene automáticamente con \fBmalloc\fP(3), y puede (y debe) liberarse con \fBfree\fP(3). La función \fBstrndup()\fP es similar, pero solamente copia como máximo \fIn\fP carácteres. Si \fIs\fP es mayor que \fIn\fP, sólo se copian \fIn\fP carácteres, y se añade un NUL al final. \fBstrdupa\fP y \fBstrndupa\fP son similares, pero usan \fBalloca(3)\fP para reservar el buffer. Sólo están disponibles cuando se usa la aplicación GNU GCC, y sufren las mismas limitaciones descritas en \fBalloca(3)\fP. .SH "VALOR DEVUELTO" La función \fBstrdup()\fP devuelve un puntero a la cadena duplicada, o NULL si no había bastante memoria. .SH "ERRORES" .TP .B ENOMEM Memoria insuficiente disponible para alojar la cadena duplicada. .SH "CONFORME A" .\" 4.3BSD-Reno, not (first) BSD 4.3. SVID 3, BSD 4.3. \fBstrndup()\fP, \fBstrdupa()\fP, y \fBstrndupa()\fP son extensiones de GNU. .SH "VÉASE TAMBIÉN" .BR alloca (3), .BR calloc (3), .BR free (3), .BR malloc (3), .BR realloc (3)