From 8b17579e608f60bb48094756107c7e500499ac5f Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Sat, 16 Apr 2005 09:20:53 +0000 Subject: private strdup() implementation in case libc does not provide it. --- src/portab/strdup.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/portab/strdup.c (limited to 'src') diff --git a/src/portab/strdup.c b/src/portab/strdup.c new file mode 100644 index 00000000..e7351570 --- /dev/null +++ b/src/portab/strdup.c @@ -0,0 +1,35 @@ +/* + * ngIRCd -- The Next Generation IRC Daemon + * + * strdup() implementation. Public domain. + * + * $Id: strdup.c,v 1.1 2005/04/16 09:20:53 fw Exp $ + */ + +#include "portab.h" + +#include "imp.h" +#include +#include +#include + +#include "exp.h" + +#ifndef HAVE_STRDUP + +GLOBAL char * +strdup( const char *s ) +{ + char *dup; + size_t len = strlen( s ); + size_t alloc = len + 1; + + if (len >= alloc ) return NULL; + dup = malloc( alloc ); + if (dup) strlcpy(dup, s, alloc ); + +return dup; +} + +#endif + -- cgit 1.4.1