view Python/strdup.c @ 9383:2b34461ba4a3 legacy-trunk

PyMapping_SetItemString() returns int, not an object.
author Guido van Rossum <guido@python.org>
date Fri, 16 Oct 1998 17:43:53 +0000
parents bb5b9ff72de1
children 8efa37a770c6
line wrap: on
line source

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