1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

add smb_xvasprintf() panic wrapper around vasprintf

(This used to be commit fa1e7a62ac)
This commit is contained in:
Andrew Tridgell 2001-12-09 23:56:07 +00:00
parent f13f9940b7
commit e3d171ff55

View File

@ -1757,7 +1757,6 @@ int smb_mkstemp(char *template)
/** /**
malloc that aborts with smb_panic on fail or zero size. malloc that aborts with smb_panic on fail or zero size.
**/ **/
void *smb_xmalloc(size_t size) void *smb_xmalloc(size_t size)
{ {
void *p; void *p;
@ -1771,7 +1770,6 @@ void *smb_xmalloc(size_t size)
/** /**
Memdup with smb_panic on fail. Memdup with smb_panic on fail.
**/ **/
void *smb_xmemdup(const void *p, size_t size) void *smb_xmemdup(const void *p, size_t size)
{ {
void *p2; void *p2;
@ -1783,7 +1781,6 @@ void *smb_xmemdup(const void *p, size_t size)
/** /**
strdup that aborts on malloc fail. strdup that aborts on malloc fail.
**/ **/
char *smb_xstrdup(const char *s) char *smb_xstrdup(const char *s)
{ {
char *s1 = strdup(s); char *s1 = strdup(s);
@ -1792,6 +1789,19 @@ char *smb_xstrdup(const char *s)
return s1; 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 like strdup but for memory
*****************************************************************/ *****************************************************************/