backport
[AROS.git] / compiler / clib / strdup.c
blob4bb08dfb65150abcf358d6edf6b7f87df8130305
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C 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 */