From 26fc20187d405702c50d1e7a38d3a94c84932bed Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Aug 2002 22:53:33 +0000 Subject: added smb_xstrndup() --- source/lib/util.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source') 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 */ -- cgit