summaryrefslogtreecommitdiff
path: root/source3/lib/util_str.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util_str.c')
-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