summaryrefslogtreecommitdiff
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
commitfa1e7a62acdbcc550e6b29dc69454dcf7472210d (patch)
tree7ac696998292aeb0ae2f83b0b3bee770deb05ab6
parent3a3b3469e66e25531f4531dce8a1d7bc9c17896e (diff)
downloadsamba-fa1e7a62acdbcc550e6b29dc69454dcf7472210d.tar.gz
add smb_xvasprintf() panic wrapper around vasprintf
-rw-r--r--source/lib/util.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/source/lib/util.c b/source/lib/util.c
index a8e2bcb7f58..55bb3647fc8 100644
--- a/source/lib/util.c
+++ b/source/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
*****************************************************************/