1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
/*
* Copyright 1994-2000 World Wide Web Consortium
* See http://www.w3.org/Consortium/Legal/copyright-software
*
* Author: Bert Bos <bert@w3.org>
* Created: 31 Mar 2000
* Version: $Id: strdup.c,v 1.2 2007/10/23 11:17:08 bbos Exp $
**/
#include <config.h>
#include <stdlib.h>
#include "export.h"
#ifndef HAVE_STRDUP
/* strdup -- allocate a copy of a string on the heap; NULL if no memory */
EXPORT char *strdup(const char *s)
{
char *t;
if ((t = malloc((strlen(s) + 1) * sizeof(*s)))) strcpy(t, s);
return t;
}
#endif /* HAVE_STRDUP */
|