sdlStrstr function

Pointer<Int8> sdlStrstr(
  1. String? haystack,
  2. String? needle
)
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle)

Implementation

Pointer<Int8> sdlStrstr(String? haystack, String? needle) {
  final sdlStrstrLookupFunction = libSdl2.lookupFunction<
      Pointer<Int8> Function(Pointer<Utf8> haystack, Pointer<Utf8> needle),
      Pointer<Int8> Function(
          Pointer<Utf8> haystack, Pointer<Utf8> needle)>('SDL_strstr');
  final haystackPointer = haystack != null ? haystack.toNativeUtf8() : nullptr;
  final needlePointer = needle != null ? needle.toNativeUtf8() : nullptr;
  final result = sdlStrstrLookupFunction(haystackPointer, needlePointer);
  calloc.free(haystackPointer);
  calloc.free(needlePointer);
  return result;
}