/* STRDUP.C by Fergus Patrick Duniho. Public Domain */

#ifndef _STRDUP_C
#define _STRDUP_C

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

char *strdup (char *s);

char *strdup (char *s) {
    char *r;

    if ((r = (char *)malloc(strlen(s) + 1)) == NULL) {
      perror ("Malloc cannot allocate enough memory for a new string.\n");
      exit (2);
    }
    strcpy (r, s);
    return r;
}

#endif /* _STRDUP_C */
