From c032c2b36432d91cab4dbaf1ea4009b1194c4ccc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 22 Oct 2001 02:38:45 +0000 Subject: Added xstrdup, removed static version from smbpasswd.c Jeremy. (This used to be commit d01a9e5974d80ee8be2f7a20aeaae5826325d035) --- source3/lib/util.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index cd170ff3d3..90bb462d0e 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1649,9 +1649,9 @@ void *xmalloc(size_t size) { void *p; if (size == 0) - smb_panic("xmalloc called with zero size.\n"); + smb_panic("xmalloc: called with zero size.\n"); if ((p = malloc(size)) == NULL) - smb_panic("xmalloc malloc fail.\n"); + smb_panic("xmalloc: malloc fail.\n"); return p; } @@ -1667,6 +1667,18 @@ void *xmemdup(void *p, size_t size) return p2; } +/***************************************************************** + strdup that aborts on malloc fail. + *****************************************************************/ + +char *xstrdup(const char *s) +{ + char *s1 = strdup(s); + if (!s1) + smb_panic("xstrdup: malloc fail\n"); + return s1; +} + /***************************************************************** like strdup but for memory *****************************************************************/ -- cgit