sdlVsnprintf function stdinc
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.2.0.
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<Int8> text, int maxlen, String? fmt) {
final sdlVsnprintfLookupFunction = _libSdl
.lookupFunction<
Int32 Function(Pointer<Int8> text, Uint32 maxlen, Pointer<Utf8> fmt),
int Function(Pointer<Int8> text, int maxlen, Pointer<Utf8> fmt)
>('SDL_vsnprintf');
final fmtPointer = fmt != null ? fmt.toNativeUtf8() : nullptr;
final result = sdlVsnprintfLookupFunction(text, maxlen, fmtPointer);
calloc.free(fmtPointer);
return result;
}