add fmt_strm_malloc

master
Felix von Leitner 2020-12-07 17:53:24 +00:00
parent bd5461a618
commit 40a5ae7d3b
1 changed files with 2 additions and 0 deletions

2
fmt.h
View File

@ -291,6 +291,8 @@ size_t fmt_strm_internal(char* dest,...) noexcept;
#endif
#define fmt_strm_alloca(a,...) ({ size_t len=fmt_strm((char*)0,a,__VA_ARGS__)+1; char* c=(len<MAX_ALLOCA?alloca(len):0); if (c) c[fmt_strm(c,a,__VA_ARGS__)]=0; c;})
#define fmt_strm_malloc(a,...) ({ size_t len=fmt_strm((char*)0,a,__VA_ARGS__)+1; char* c=(len<MAX_ALLOCA?malloc(len):0); if (c) c[fmt_strm(c,a,__VA_ARGS__)]=0; c;})
#ifdef __cplusplus
}
#endif