sdlVasprintf function
This works exactly like vasprintf() but doesn't require access to a C runtime.
Functions identically to SDL_asprintf(), except it takes a va_list
instead of using ...
variable arguments.
\param strp on output, is set to the new string. Must not be NULL.
\param fmt a printf-style format string. Must not be NULL.
\param ap a va_list
values to be used with the format string.
\returns the number of bytes in the newly-allocated string, not counting
the null-terminator char, or a negative value on error.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.1.3.
extern SDL_DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2)
Implementation
int sdlVasprintf(
Pointer<Pointer<Int8>> strp, String? fmt, Pointer<NativeType> arg2) {
final sdlVasprintfLookupFunction = libSdl3.lookupFunction<
Int32 Function(Pointer<Pointer<Int8>> strp, Pointer<Utf8> fmt,
Pointer<NativeType> arg2),
int Function(Pointer<Pointer<Int8>> strp, Pointer<Utf8> fmt,
Pointer<NativeType> arg2)>('SDL_vasprintf');
final fmtPointer = fmt != null ? fmt.toNativeUtf8() : nullptr;
final result = sdlVasprintfLookupFunction(strp, fmtPointer, arg2);
calloc.free(fmtPointer);
return result;
}