commit 8b17579e608f60bb48094756107c7e500499ac5f from: Florian Westphal date: Sat Apr 16 09:20:53 2005 UTC private strdup() implementation in case libc does not provide it. commit - b4363162cede49f959d0d11f3d08d05e9854c740 commit + 8b17579e608f60bb48094756107c7e500499ac5f blob - /dev/null blob + e735157043084d633e84ff7a9b578bca4e832a12 (mode 644) --- /dev/null +++ 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 +