]> arthur.barton.de Git - ngircd-alex.git/blob - src/portab/strdup.c
e735157043084d633e84ff7a9b578bca4e832a12
[ngircd-alex.git] / src / portab / strdup.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  *
4  * strdup() implementation.  Public domain.
5  *
6  * $Id: strdup.c,v 1.1 2005/04/16 09:20:53 fw Exp $
7  */
8
9 #include "portab.h"
10
11 #include "imp.h"
12 #include <string.h>
13 #include <stdlib.h>
14 #include <sys/types.h>
15
16 #include "exp.h"
17
18 #ifndef HAVE_STRDUP
19
20 GLOBAL char *
21 strdup( const char *s )
22 {
23  char *dup;
24  size_t len = strlen( s );
25  size_t alloc = len + 1;
26
27  if (len >= alloc ) return NULL;
28  dup = malloc( alloc );
29  if (dup) strlcpy(dup, s, alloc );
30
31 return dup;
32 }
33
34 #endif
35