sdlSetenvUnsafe function

int sdlSetenvUnsafe(
  1. String? name,
  2. String? value,
  3. int overwrite
)

Set the value of a variable in the environment.

\param name the name of the variable to set. \param value the value of the variable to set. \param overwrite 1 to overwrite the variable if it exists, 0 to return success without setting the variable if it already exists. \returns 0 on success, -1 on error.

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

\since This function is available since SDL 3.1.3.

\sa SDL_SetEnvironmentVariable

extern SDL_DECLSPEC int SDLCALL SDL_setenv_unsafe(const char *name, const char *value, int overwrite)

Implementation

int sdlSetenvUnsafe(String? name, String? value, int overwrite) {
  final sdlSetenvUnsafeLookupFunction = libSdl3.lookupFunction<
      Int32 Function(Pointer<Utf8> name, Pointer<Utf8> value, Int32 overwrite),
      int Function(Pointer<Utf8> name, Pointer<Utf8> value,
          int overwrite)>('SDL_setenv_unsafe');
  final namePointer = name != null ? name.toNativeUtf8() : nullptr;
  final valuePointer = value != null ? value.toNativeUtf8() : nullptr;
  final result =
      sdlSetenvUnsafeLookupFunction(namePointer, valuePointer, overwrite);
  calloc.free(namePointer);
  calloc.free(valuePointer);
  return result;
}