sdlUtf8strnlen function

int sdlUtf8strnlen(
  1. String? str,
  2. int bytes
)
extern DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes)

Implementation

int sdlUtf8strnlen(String? str, int bytes) {
  final sdlUtf8strnlenLookupFunction = libSdl2.lookupFunction<
      Uint32 Function(Pointer<Utf8> str, Uint32 bytes),
      int Function(Pointer<Utf8> str, int bytes)>('SDL_utf8strnlen');
  final strPointer = str != null ? str.toNativeUtf8() : nullptr;
  final result = sdlUtf8strnlenLookupFunction(strPointer, bytes);
  calloc.free(strPointer);
  return result;
}