view Python/strdup.c @ 74806:c19be14466e8 3.2

bltinmod is borrowed, so it shouldn't be decrefed
author Benjamin Peterson <benjamin@python.org>
date Mon, 06 Feb 2012 11:28:45 -0500
parents f79434ee41fa
children e7f6cef7a4cc
line wrap: on
line source

/* 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;
}