Staging
v0.5.1
https://github.com/python/cpython
Revision c44d3d666424d5fe8ae635ee1c0e4ca1fb9539b2 authored by Guido van Rossum on 06 October 1997, 05:10:47 UTC, committed by Guido van Rossum on 06 October 1997, 05:10:47 UTC
1 parent 86b7db3
Raw File
Tip revision: c44d3d666424d5fe8ae635ee1c0e4ca1fb9539b2 authored by Guido van Rossum on 06 October 1997, 05:10:47 UTC
Done with tread state descriptions. Sigh!
Tip revision: c44d3d6
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