From e3d171ff55c7afec6687616a3808637f2d4cf456 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 9 Dec 2001 23:56:07 +0000 Subject: add smb_xvasprintf() panic wrapper around vasprintf (This used to be commit fa1e7a62acdbcc550e6b29dc69454dcf7472210d) --- source3/lib/util.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index a8e2bcb7f5..55bb3647fc 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1757,7 +1757,6 @@ int smb_mkstemp(char *template) /** malloc that aborts with smb_panic on fail or zero size. **/ - void *smb_xmalloc(size_t size) { void *p; @@ -1771,7 +1770,6 @@ void *smb_xmalloc(size_t size) /** Memdup with smb_panic on fail. **/ - void *smb_xmemdup(const void *p, size_t size) { void *p2; @@ -1783,7 +1781,6 @@ void *smb_xmemdup(const void *p, size_t size) /** strdup that aborts on malloc fail. **/ - char *smb_xstrdup(const char *s) { char *s1 = strdup(s); @@ -1792,6 +1789,19 @@ char *smb_xstrdup(const char *s) return s1; } +/* + vasprintf that aborts on malloc fail +*/ +int smb_xvasprintf(char **ptr, const char *format, va_list ap) +{ + int n; + n = vasprintf(ptr, format, ap); + if (n == -1 || ! *ptr) { + smb_panic("smb_xvasprintf: out of memory"); + } + return n; +} + /***************************************************************** like strdup but for memory *****************************************************************/ -- cgit