sdlStrdup function

Pointer<Int8> sdlStrdup(
  1. String? str
)
extern DECLSPEC char *SDLCALL SDL_strdup(const char *str)

Implementation

Pointer<Int8> sdlStrdup(String? str) {
  final sdlStrdupLookupFunction = libSdl2.lookupFunction<
      Pointer<Int8> Function(Pointer<Utf8> str),
      Pointer<Int8> Function(Pointer<Utf8> str)>('SDL_strdup');
  final strPointer = str != null ? str.toNativeUtf8() : nullptr;
  final result = sdlStrdupLookupFunction(strPointer);
  calloc.free(strPointer);
  return result;
}