mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-10 05:08:11 -05:00
Merge branch 'string_printf' of git://github.com/chme/forked-daapd into chme-string_printf
This commit is contained in:
commit
dcf75f59eb
23
src/misc.c
23
src/misc.c
@ -32,6 +32,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#ifndef CLOCK_REALTIME
|
#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);
|
DPRINTF(E_FATAL, domain, "%s returned NULL at line %d\n", func, line);
|
||||||
abort();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,4 +201,6 @@ log_fatal_errno(int domain, const char *func, int line) __attribute__((__
|
|||||||
void
|
void
|
||||||
log_fatal_null(int domain, const char *func, int line) __attribute__((__noreturn__));
|
log_fatal_null(int domain, const char *func, int line) __attribute__((__noreturn__));
|
||||||
|
|
||||||
|
char *string_printf(const char *fmt, ...);
|
||||||
|
|
||||||
#endif /* !__MISC_H__ */
|
#endif /* !__MISC_H__ */
|
||||||
|
@ -244,9 +244,9 @@ spotifywebapi_request_next(struct spotify_request *request, const char *uri, boo
|
|||||||
if (append_market && spotify_user_country)
|
if (append_market && spotify_user_country)
|
||||||
{
|
{
|
||||||
if (strchr(uri, '?'))
|
if (strchr(uri, '?'))
|
||||||
asprintf(&next_uri, "%s&market=%s", uri, spotify_user_country);
|
next_uri = string_printf("%s&market=%s", uri, spotify_user_country);
|
||||||
else
|
else
|
||||||
asprintf(&next_uri, "%s?market=%s", uri, spotify_user_country);
|
next_uri = string_printf("%s?market=%s", uri, spotify_user_country);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
next_uri = strdup(uri);
|
next_uri = strdup(uri);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user