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