summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-04-11 15:27:22 +0000
committerAndrew Tridgell <tridge@samba.org>2002-04-11 15:27:22 +0000
commit5928c293ff5d0b864172b559cb82d1aa089d9a4a (patch)
tree86a4addf66afc3d5d61158b98b44bb2f02f1c65a /source3/lib
parent41b81371697de322789e50ae25e742025ca408ca (diff)
downloadsamba-5928c293ff5d0b864172b559cb82d1aa089d9a4a.tar.gz
samba-5928c293ff5d0b864172b559cb82d1aa089d9a4a.tar.bz2
samba-5928c293ff5d0b864172b559cb82d1aa089d9a4a.zip
added strndup() for systems that don't have it
(This used to be commit 7e92fb7453e4dbf1fe0c32c3dcc1e994cb95b5ea)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_str.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index e3dd3124a5..6fdca658cd 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -982,3 +982,22 @@ int fstr_sprintf(fstring s, const char *fmt, ...)
va_end(ap);
return ret;
}
+
+
+#ifndef HAVE_STRNDUP
+/*******************************************************************
+some platforms don't have strndup
+********************************************************************/
+ char *strndup(const char *s, size_t n)
+{
+ char *ret;
+ int i;
+ for (i=0;s[i] && i<n;i++) ;
+
+ ret = malloc(i+1);
+ if (!ret) return NULL;
+ memcpy(ret, s, i);
+ ret[i] = 0;
+ return ret;
+}
+#endif