]> arthur.barton.de Git - ngircd-alex.git/commitdiff
private strdup() implementation in case libc does not provide it.
authorFlorian Westphal <fw@strlen.de>
Sat, 16 Apr 2005 09:20:53 +0000 (09:20 +0000)
committerFlorian Westphal <fw@strlen.de>
Sat, 16 Apr 2005 09:20:53 +0000 (09:20 +0000)
src/portab/strdup.c [new file with mode: 0644]

diff --git a/src/portab/strdup.c b/src/portab/strdup.c
new file mode 100644 (file)
index 0000000..e735157
--- /dev/null
@@ -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 <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#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
+