ack/lang/cem/libcc.ansi/core/string/strdup.c

18 lines
343 B
C
Raw Normal View History

/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
2018-06-17 13:42:26 +00:00
#include <stdlib.h>
#include <string.h>
2018-06-21 20:33:47 +00:00
char* strdup(const char* s)
{
int len = strlen(s);
2018-06-21 20:33:47 +00:00
char* p = malloc(len + 1);
if (p)
2018-06-21 20:33:47 +00:00
memcpy(p, s, len + 1);
return p;
}