Firstly, calling SDL_SetPropertyWithCleanup with value: NULL will not call the cleanup function. This is technically not in violation of the documentation. But it is strange that you can provide a cleanup function knowing that it'll never be called.
More importantly, if the SDL_calloc fails, the cleanup function (for the value that is being set) will never be called.
SDL_PrivateSetProperty also doesn't clean up on failure.
The documentation could be wrong. But I can't think of a reason why you wouldn't want the cleanup function to clean up on failure.
The docs say:
https://github.com/libsdl-org/SDL/blob/3f2f712fffcfa07dbba48e88aff24006ab012f21/include/SDL3/SDL_properties.h#L151-L152
The current implementation is as follows:
https://github.com/libsdl-org/SDL/blob/3f2f712fffcfa07dbba48e88aff24006ab012f21/src/SDL_properties.c#L341-L359
Firstly, calling
SDL_SetPropertyWithCleanup
withvalue: NULL
will not call the cleanup function. This is technically not in violation of the documentation. But it is strange that you can provide a cleanup function knowing that it'll never be called.More importantly, if the
SDL_calloc
fails, the cleanup function (for the value that is being set) will never be called.SDL_PrivateSetProperty
also doesn't clean up on failure.The documentation could be wrong. But I can't think of a reason why you wouldn't want the cleanup function to clean up on failure.