about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2005-04-16 09:20:53 +0000
committerFlorian Westphal <fw@strlen.de>2005-04-16 09:20:53 +0000
commit8b17579e608f60bb48094756107c7e500499ac5f (patch)
treeb3b28601118392b40f51db6584303f32f5bc6e36
parentb4363162cede49f959d0d11f3d08d05e9854c740 (diff)
downloadngircd-8b17579e608f60bb48094756107c7e500499ac5f.tar.gz
ngircd-8b17579e608f60bb48094756107c7e500499ac5f.zip
private strdup() implementation in case libc does not provide it.
-rw-r--r--src/portab/strdup.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/portab/strdup.c b/src/portab/strdup.c
new file mode 100644
index 00000000..e7351570
--- /dev/null
+++ b/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 <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
+