sdlStrstr function
Search a string for the first instance of a specific substring.
The search ends once it finds the requested substring, or a null terminator byte to end the string.
Note that this looks for strings of bytes, not characters, so it's legal to search for malformed and incomplete UTF-8 sequences.
\param haystack the string to search. Must not be NULL.
\param needle the string to search for. Must not be NULL.
\returns a pointer to the first instance of needle
in the string, or NULL
if not found.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.1.3.
extern SDL_DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle)
Implementation
Pointer<Int8> sdlStrstr(String? haystack, String? needle) {
final sdlStrstrLookupFunction = libSdl3.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;
}