1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

utils: replace str() and strv() macros by functions to avoid compiler warnings

This commit is contained in:
Steffen Vogel 2019-03-26 06:49:41 +01:00
parent 8c18803ccc
commit 90a53bcd7c
2 changed files with 23 additions and 3 deletions

View file

@ -196,9 +196,8 @@ char * strcatf(char **dest, const char *fmt, ...)
char * vstrcatf(char **dest, const char *fmt, va_list va)
__attribute__ ((format(printf, 2, 0)));
/** Format string like strcatf() just starting with empty string */
#define strf(fmt, ...) strcatf(&(char *) { NULL }, fmt, ##__VA_ARGS__)
#define vstrf(fmt, va) vstrcatf(&(char *) { NULL }, fmt, va)
char * strf(const char *fmt, ...);
char * vstrf(const char *fmt, va_list va);
/** Allocate and initialize memory. */
void * alloc(size_t bytes);

View file

@ -91,6 +91,27 @@ char * vstrcatf(char **dest, const char *fmt, va_list ap)
return *dest;
}
char * strf(const char *fmt, ...)
{
char *buf = NULL;
va_list ap;
va_start(ap, fmt);
vstrcatf(&buf, fmt, ap);
va_end(ap);
return buf;
}
char * vstrf(const char *fmt, va_list va)
{
char *buf = NULL;
vstrcatf(&buf, fmt, va);
return buf;
}
void * alloc(size_t bytes)
{
void *p = malloc(bytes);