sdlVsnprintf function
This works exactly like vsnprintf() but doesn't require access to a C runtime.
Functions identically to SDL_snprintf(), except it takes a va_list
instead of using ...
variable arguments.
\param text the buffer to write the string into. Must not be NULL.
\param maxlen the maximum bytes to write, including the null-terminator.
\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 that should be written, 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_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3)
Implementation
int sdlVsnprintf(Pointer<NativeType> arg0, int maxlen, String? fmt,
Pointer<NativeType> arg3) {
final sdlVsnprintfLookupFunction = libSdl3.lookupFunction<
Int32 Function(Pointer<NativeType> arg0, Uint32 maxlen, Pointer<Utf8> fmt,
Pointer<NativeType> arg3),
int Function(Pointer<NativeType> arg0, int maxlen, Pointer<Utf8> fmt,
Pointer<NativeType> arg3)>('SDL_vsnprintf');
final fmtPointer = fmt != null ? fmt.toNativeUtf8() : nullptr;
final result = sdlVsnprintfLookupFunction(arg0, maxlen, fmtPointer, arg3);
calloc.free(fmtPointer);
return result;
}