2 8b17579e 2005-04-16 fw * ngIRCd -- The Next Generation IRC Daemon
4 8b17579e 2005-04-16 fw * strdup() implementation. Public domain.
6 8b17579e 2005-04-16 fw * $Id: strdup.c,v 1.1 2005/04/16 09:20:53 fw Exp $
9 8b17579e 2005-04-16 fw #include "portab.h"
11 8b17579e 2005-04-16 fw #include "imp.h"
12 8b17579e 2005-04-16 fw #include <string.h>
13 8b17579e 2005-04-16 fw #include <stdlib.h>
14 8b17579e 2005-04-16 fw #include <sys/types.h>
16 8b17579e 2005-04-16 fw #include "exp.h"
18 8b17579e 2005-04-16 fw #ifndef HAVE_STRDUP
21 8b17579e 2005-04-16 fw strdup( const char *s )
24 8b17579e 2005-04-16 fw size_t len = strlen( s );
25 8b17579e 2005-04-16 fw size_t alloc = len + 1;
27 8b17579e 2005-04-16 fw if (len >= alloc ) return NULL;
28 8b17579e 2005-04-16 fw dup = malloc( alloc );
29 8b17579e 2005-04-16 fw if (dup) strlcpy(dup, s, alloc );