summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-08-22 22:53:33 +0000
committerAndrew Tridgell <tridge@samba.org>2002-08-22 22:53:33 +0000
commit26fc20187d405702c50d1e7a38d3a94c84932bed (patch)
treec6df8e4cc5055ba9c52fa29648a8eee54d70b85b /source
parent5ff687a839f805af56ae77cba94c466a0ff87ccc (diff)
downloadsamba-26fc20187d405702c50d1e7a38d3a94c84932bed.tar.gz
samba-26fc20187d405702c50d1e7a38d3a94c84932bed.tar.xz
samba-26fc20187d405702c50d1e7a38d3a94c84932bed.zip
added smb_xstrndup()
Diffstat (limited to 'source')
-rw-r--r--source/lib/util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/lib/util.c b/source/lib/util.c
index ae94b710b2c..bf012b97219 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -1819,6 +1819,17 @@ char *smb_xstrdup(const char *s)
return s1;
}
+/**
+ strndup that aborts on malloc fail.
+**/
+char *smb_xstrndup(const char *s, size_t n)
+{
+ char *s1 = strndup(s, n);
+ if (!s1)
+ smb_panic("smb_xstrndup: malloc fail\n");
+ return s1;
+}
+
/*
vasprintf that aborts on malloc fail
*/