Fix: 64-bit compatibility
[AROS.git] / compiler / stdc / strdup.c
blob8479f5aa1b3850a0c42be66561ddcd1e7792feda
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 POSIX.1-2008 function strdup().
6 */
8 #include <stdlib.h>
10 /*****************************************************************************
12 NAME */
13 #include <string.h>
15 char * strdup (
17 /* SYNOPSIS */
18 const char * orig)
20 /* FUNCTION
21 Create a copy of a string. The copy can be freed with free() or will
22 be freed when the program ends.
24 INPUTS
25 str1 - Strings to duplicate
27 RESULT
28 A copy of the string which can be freed with free().
30 NOTES
32 EXAMPLE
34 BUGS
36 SEE ALSO
38 INTERNALS
40 ******************************************************************************/
42 char * copy;
43 char * ptr;
45 if ((copy = malloc (strlen (orig)+1)))
47 ptr = copy;
49 while ((*ptr ++ = *orig ++));
52 return copy;
53 } /* strdup */