1/*
2 * Copyright 2003-2007, Axel D��rfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <string.h>
8#include <stdlib.h>
9
10
11char*
12strdup(const char *string)
13{
14	char* copied;
15	size_t length;
16
17	// unlike the standard strdup() function, the BeOS implementation
18	// handles NULL strings gracefully
19	if (string == NULL)
20		return NULL;
21
22	length = strlen(string) + 1;
23
24	if ((copied = (char *)malloc(length)) == NULL)
25		return NULL;
26
27	memcpy(copied, string, length);
28	return copied;
29}
30