/*
    Copyright (C) 1995-2012, The AROS Development Team. All rights reserved.

    POSIX.1-2008 function strdup().
*/

#include <stdlib.h>

/*****************************************************************************

    NAME */
#include <string.h>

        char * strdup (

/*  SYNOPSIS */
        const char * orig)

/*  FUNCTION
        Create a copy of a string. The copy can be freed with free() or will
        be freed when the program ends.

    INPUTS
        str1 - Strings to duplicate

    RESULT
        A copy of the string which can be freed with free().

    NOTES

    EXAMPLE

    BUGS

    SEE ALSO

    INTERNALS

******************************************************************************/
{
    char * copy;
    char * ptr;

    if ((copy = malloc (strlen (orig)+1)))
    {
        ptr = copy;

        while ((*ptr ++ = *orig ++));
    }

    return copy;
} /* strdup */

