spa: add spa_aprintf helper

Add a asprintf helper function that handles errors correctly.
Use this in places where we use asprintf to avoid warnings when we
don't check the return value.
This commit is contained in:
Wim Taymans 2020-01-27 12:19:21 +01:00
parent aee3191bad
commit 6ac9b7b3a7
16 changed files with 102 additions and 85 deletions

View file

@ -241,6 +241,14 @@ struct spa_fraction {
#define spa_memmove(d,s,n) memmove(d,s,n)
#endif
#define spa_aprintf(_fmt, ...) \
({ \
char *_strp; \
if (asprintf(&(_strp), (_fmt), ## __VA_ARGS__ ) == -1) \
_strp = NULL; \
_strp; \
})
#ifdef __cplusplus
} /* extern "C" */
#endif