SDL_SetPoint...tyWithCleanup(3)

✨ SDL_SetPointerPropertyWithCleanup ✨

okay bestie, so this one lives in the SDL3 FUNCTIONS part of the manual, and the page header is literally SDL_SetPoint...tyWithCleanup(3) because the name is so long the terminal had to squish it πŸ’€. Anyway. We're setting a pointer property in a group of properties, and we're attaching a cleanup function that gets called when that property gets deleted. It's giving ✨responsible ownership✨.


🌸 NAME 🌸

SDL_SetPointerPropertyWithCleanup β€” set a pointer property in a group of properties, with a cleanup function that gets called when the property is deleted. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_properties.h>

bool SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, SDL_CleanupPropertyCallback cleanup, void *userdata);

πŸ’– DESCRIPTION πŸ’–

So the tea is: that cleanup function also gets called if setting the property fails for any reason. Yes, any reason. She's committed. 😭

Now listen β€” if you're just setting basic data types, like numbers, bools, or strings, please use SDL_SetNumberProperty, SDL_SetBooleanProperty, or SDL_SetStringProperty instead, because those functions will handle cleanup on your behalf, no cap. This function right here is only for more complex, custom data. It's the main character function for main character data πŸ‘‘.


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • props β€” the properties to modify. your little property group, your canvas 🫢
  • name β€” the name of the property to modify. like, the label on the box πŸ’…
  • value β€” the new value of the property, or NULL to delete the property. yep, NULL = delete, that's the move πŸ—‘οΈ
  • cleanup β€” the function to call when this property is deleted, or NULL if no cleanup is necessary. if you got nothing to clean, pass NULL and vibe ✨
  • userdata β€” a pointer that is passed to the cleanup function. your little gift basket for the cleanup function 🎁

πŸ”₯ RETURN VALUE πŸ”₯

Returns true on success or false on failure. If it fails, call SDL_GetError() for more information β€” she will tell you what went wrong, fr fr πŸ’€


🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread. multi-threaded queen behavior, we love to see it πŸ‘‘


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. so if you're on something older... girl. upgrade. πŸ™ˆ


πŸ’œ SEE ALSO πŸ’œ


and that's the whole page, bestie!! this was brought to you by Simple Directmedia Layer, rocking SDL 3.4.18 β€” go off, you got this πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from