sdlGetPointerProperty function

Pointer<NativeType> sdlGetPointerProperty(
  1. int props,
  2. String? name,
  3. Pointer<NativeType> defaultValue
)

Get a pointer property from a group of properties.

By convention, the names of properties that SDL exposes on objects will start with "SDL.", and properties that SDL uses internally will start with "SDL.internal.". These should be considered read-only and should not be modified by applications.

\param props the properties to query. \param name the name of the property to query. \param default_value the default value of the property. \returns the value of the property, or default_value if it is not set or not a pointer property.

\threadsafety It is safe to call this function from any thread, although the data returned is not protected and could potentially be freed if you call SDL_SetPointerProperty() or SDL_ClearProperty() on these properties from another thread. If you need to avoid this, use SDL_LockProperties() and SDL_UnlockProperties().

\since This function is available since SDL 3.1.3.

\sa SDL_GetBooleanProperty \sa SDL_GetFloatProperty \sa SDL_GetNumberProperty \sa SDL_GetPropertyType \sa SDL_GetStringProperty \sa SDL_HasProperty \sa SDL_SetPointerProperty

extern SDL_DECLSPEC void * SDLCALL SDL_GetPointerProperty(SDL_PropertiesID props, const char *name, void *default_value)

Implementation

Pointer<NativeType> sdlGetPointerProperty(
    int props, String? name, Pointer<NativeType> defaultValue) {
  final sdlGetPointerPropertyLookupFunction = libSdl3.lookupFunction<
      Pointer<NativeType> Function(
          Uint32 props, Pointer<Utf8> name, Pointer<NativeType> defaultValue),
      Pointer<NativeType> Function(int props, Pointer<Utf8> name,
          Pointer<NativeType> defaultValue)>('SDL_GetPointerProperty');
  final namePointer = name != null ? name.toNativeUtf8() : nullptr;
  final result =
      sdlGetPointerPropertyLookupFunction(props, namePointer, defaultValue);
  calloc.free(namePointer);
  return result;
}