mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 15:45:56 -05:00
[misc] Add string_printf function
This commit is contained in:
parent
4423cd4ce6
commit
4e6b78ca29
23
src/misc.c
23
src/misc.c
@ -32,6 +32,7 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
#ifndef CLOCK_REALTIME
|
||||
@ -1132,3 +1133,25 @@ log_fatal_null(int domain, const char *func, int line)
|
||||
DPRINTF(E_FATAL, domain, "%s returned NULL at line %d\n", func, line);
|
||||
abort();
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapper function for vasprintf by Intel Corporation
|
||||
* Published under the L-GPL 2.1 licence as part of clr-boot-manager
|
||||
*
|
||||
* https://github.com/clearlinux/clr-boot-manager
|
||||
*/
|
||||
char *string_printf(const char *fmt, ...)
|
||||
{
|
||||
char *ret = NULL;
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
if (vasprintf(&ret, fmt, va) < 0)
|
||||
{
|
||||
DPRINTF(E_FATAL, L_MISC, "Out of memory for string_printf\n");
|
||||
abort();
|
||||
}
|
||||
va_end(va);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -196,4 +196,6 @@ void log_fatal_err(int domain, const char *func, int line, int err);
|
||||
void log_fatal_errno(int domain, const char *func, int line);
|
||||
void log_fatal_null(int domain, const char *func, int line);
|
||||
|
||||
char *string_printf(const char *fmt, ...);
|
||||
|
||||
#endif /* !__MISC_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user