sdlUnsetEnvironmentVariable function

bool sdlUnsetEnvironmentVariable(
  1. Pointer<SdlEnvironment> env,
  2. String? name
)

Clear a variable from the environment.

\param env the environment to modify. \param name the name of the variable to unset. \returns true on success or false on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.1.3.

\sa SDL_GetEnvironment \sa SDL_CreateEnvironment \sa SDL_GetEnvironmentVariable \sa SDL_GetEnvironmentVariables \sa SDL_SetEnvironmentVariable \sa SDL_UnsetEnvironmentVariable

extern SDL_DECLSPEC bool SDLCALL SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name)

Implementation

bool sdlUnsetEnvironmentVariable(Pointer<SdlEnvironment> env, String? name) {
  final sdlUnsetEnvironmentVariableLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<SdlEnvironment> env, Pointer<Utf8> name),
      int Function(Pointer<SdlEnvironment> env,
          Pointer<Utf8> name)>('SDL_UnsetEnvironmentVariable');
  final namePointer = name != null ? name.toNativeUtf8() : nullptr;
  final result =
      sdlUnsetEnvironmentVariableLookupFunction(env, namePointer) == 1;
  calloc.free(namePointer);
  return result;
}