summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-12-09 23:56:07 +0000
committerAndrew Tridgell <tridge@samba.org>2001-12-09 23:56:07 +0000
commite3d171ff55c7afec6687616a3808637f2d4cf456 (patch)
tree134052d0f72c0e3aeb888fc0744c8eee9ea8a2e7 /source3/lib
parentf13f9940b7c6ca5d3ab4935b3fd042e6772c650d (diff)
downloadsamba-e3d171ff55c7afec6687616a3808637f2d4cf456.tar.gz
samba-e3d171ff55c7afec6687616a3808637f2d4cf456.tar.bz2
samba-e3d171ff55c7afec6687616a3808637f2d4cf456.zip
add smb_xvasprintf() panic wrapper around vasprintf
(This used to be commit fa1e7a62acdbcc550e6b29dc69454dcf7472210d)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c16
1 files changed, 13 insertions, 3 deletions
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
*****************************************************************/