roken: Add easprintf() and evasprintf() utils
Like emalloc() and ecalloc(): errx on ENOMEM.
This commit is contained in:
@@ -563,6 +563,18 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
|||||||
__attribute__ ((__format__ (__printf__, 3, 0)));
|
__attribute__ ((__format__ (__printf__, 3, 0)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_EVASPRINTF) || defined(NEED_EVASPRINTF_PROTO)
|
||||||
|
#define evasprintf rk_evasprintf
|
||||||
|
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
|
||||||
|
rk_evasprintf(const char *format, va_list args);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_EASPRINTF) || defined(NEED_EASPRINTF_PROTO)
|
||||||
|
#define easprintf rk_easprintf
|
||||||
|
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
|
||||||
|
rk_easprintf(const char *format, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
#ifndef HAVE_STRDUP
|
||||||
#define strdup rk_strdup
|
#define strdup rk_strdup
|
||||||
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strdup(const char *);
|
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strdup(const char *);
|
||||||
|
@@ -701,3 +701,30 @@ rk_vsnprintf (char *str, size_t sz, const char *format, va_list args)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_EVASPRINTF) || defined(TEST_SNPRINTF)
|
||||||
|
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
|
||||||
|
rk_evasprintf(const char *format, va_list args)
|
||||||
|
{
|
||||||
|
char *s = NULL;
|
||||||
|
|
||||||
|
if (vasprintf(&s, format, args) == -1 || s == NULL)
|
||||||
|
errx(1, "Out of memory");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_EASPRINTF) || defined(TEST_SNPRINTF)
|
||||||
|
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
|
||||||
|
rk_easprintf(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
char *s = NULL;
|
||||||
|
|
||||||
|
va_start(args, format);
|
||||||
|
if (vasprintf(&s, format, args) == -1 || s == NULL)
|
||||||
|
errx(1, "Out of memory");
|
||||||
|
va_end(args);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@@ -52,12 +52,14 @@ HEIMDAL_ROKEN_2.0 {
|
|||||||
rk_dns_string_to_type;
|
rk_dns_string_to_type;
|
||||||
rk_dns_type_to_string;
|
rk_dns_type_to_string;
|
||||||
rk_dumpdata;
|
rk_dumpdata;
|
||||||
|
rk_easprintf;
|
||||||
rk_ecalloc;
|
rk_ecalloc;
|
||||||
rk_emalloc;
|
rk_emalloc;
|
||||||
rk_eread;
|
rk_eread;
|
||||||
rk_erealloc;
|
rk_erealloc;
|
||||||
rk_esetenv;
|
rk_esetenv;
|
||||||
rk_estrdup;
|
rk_estrdup;
|
||||||
|
rk_evasprintf;
|
||||||
rk_ewrite;
|
rk_ewrite;
|
||||||
rk_flock;
|
rk_flock;
|
||||||
rk_fnmatch;
|
rk_fnmatch;
|
||||||
|
Reference in New Issue
Block a user