sdlGetenvUnsafe function

String? sdlGetenvUnsafe(
  1. String? name
)

Get the value of a variable in the environment.

This function bypasses SDL's cached copy of the environment and is not thread-safe.

\param name the name of the variable to get. \returns a pointer to the value of the variable or NULL if it can't be found.

\threadsafety This function is not thread safe, consider using SDL_getenv() instead.

\since This function is available since SDL 3.1.3.

\sa SDL_getenv

extern SDL_DECLSPEC const char * SDLCALL SDL_getenv_unsafe(const char *name)

Implementation

String? sdlGetenvUnsafe(String? name) {
  final sdlGetenvUnsafeLookupFunction = libSdl3.lookupFunction<
      Pointer<Utf8> Function(Pointer<Utf8> name),
      Pointer<Utf8> Function(Pointer<Utf8> name)>('SDL_getenv_unsafe');
  final namePointer = name != null ? name.toNativeUtf8() : nullptr;
  final result = sdlGetenvUnsafeLookupFunction(namePointer);
  calloc.free(namePointer);
  if (result == nullptr) {
    return null;
  }
  return result.toDartString();
}