Staging
v0.5.1
https://github.com/python/cpython
Revision eaf3c9bed79cc6d509ac40fadaae93e5fcdcc0b9 authored by Jack Jansen on 15 August 1997, 14:36:45 UTC, committed by Jack Jansen on 15 August 1997, 14:36:45 UTC
1 parent 69b43ed
Raw File
Tip revision: eaf3c9bed79cc6d509ac40fadaae93e5fcdcc0b9 authored by Jack Jansen on 15 August 1997, 14:36:45 UTC
Added #include <string.h> for memcpy()
Tip revision: eaf3c9b
strdup.c
/* strdup() replacement (from stdwin, if you must know) */

#include "config.h"
#include "myproto.h"
#include "mymalloc.h"

#include <string.h>

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