SDL_Cleanu...rtyCallback(3type)

πŸ’– SDL_CleanupPropertyCallback πŸ’–

okay bestie, so this one lives in the SDL3 DATATYPES section of the manual, and it's literally the lil callback you hand over when you want something cleaned up after a property gets yeeted. no cap. 🧹✨


✨ NAME ✨

SDL_CleanupPropertyCallback β€” a callback used to free resources when a property is deleted.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_properties.h>

typedef void (SDLCALL *SDL_CleanupPropertyCallback)(void *userdata, void *value);

πŸ¦‹ DESCRIPTION πŸ¦‹

So basically: this is the function that goes "okay girl, time to let go" and releases any resources associated with value that are no longer needed. it's giving responsible. it's giving cleanup era. πŸ’…

this callback is set per-property. like, different properties in the same group can have totally different cleanup callbacks, and that's iconic actually. each one does its own thing. πŸ‘‘

and here's the part you need to clock: this callback will be called _during_ SDL_SetPointerPropertyWithCleanup if the function fails for any reason. not after, not whenever, during. iykyk. 🫢


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • userdata β€” an app-defined pointer that gets passed to the callback. it's yours, you brought it, you get it back. πŸ’–
  • value β€” the pointer that was assigned to the property, and the thing you're cleaning up. bye bestie 🫑

πŸ”₯ THREAD SAFETY πŸ”₯

ngl this is the spicy part: this callback may fire without any locks held. so if that's a concern for you (and lowkey it might be), the app should provide its own locking. the callback is not gonna do it for you, it's not your mom. πŸ˜­πŸ”’


⭐ AVAILABILITY ⭐

this datatype has been available since SDL 3.2.0. she's new, she's fresh, she's here. 🌈


🌸 SEE ALSO 🌸


reminder bestie: this is a typedef, not a function you call yourself. you write the function, you hand it over, SDL does the rest. main character energy but make it plumbing. πŸ’œ

and that's the whole page!! brought to you by the legends over at Simple Directmedia Layer, straight out of SDL 3.4.18 πŸŽ€ stay clean, stay cute, and clean up your properties. mwah!! πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from