shithub: riscv

ref: c2aa8c997aa9f7a6f0bc6cb1ad99cccede44fc72
dir: /sys/src/cmd/python/Python/strdup.c/

View raw version
/* strdup() replacement (from stdwin, if you must know) */

#include "pgenheaders.h"

char *
strdup(const char *str)
{
	if (str != NULL) {
		register char *copy = malloc(strlen(str) + 1);
		if (copy != NULL)
			return strcpy(copy, str);
	}
	return NULL;
}