SDL
SDL copied to clipboard
alloc api having new attributes for micro optimisations.
- SDL_MALLOC when the pointer returned is not aliased.
- SDL_ALLOC_SIZE* to gives hint about the size.
GCC 11 added attribute malloc (deallocator, ptr-index)
which detects mismatched allocation and deallocation functions (like the one found in 4ada14a) . It could be useful for objects that need a specific deallocator like SDL_CreateRGBSurface()
/SDL_FreeSurface()
.
example:
__attribute__((malloc, malloc (fclose, 1))) FILE* fopen(const char*, const char*);
https://gcc.gnu.org/onlinedocs/gcc-11.3.0/gcc/Common-Function-Attributes.html#Common-Function-Attributes
GCC 11 added attribute
malloc (deallocator, ptr-index)
which detects mismatched allocation and deallocation functions (like the one found in 4ada14a) . It could be useful for objects that need a specific deallocator likeSDL_CreateRGBSurface()
/SDL_FreeSurface()
.example:
__attribute__((malloc, malloc (fclose, 1))) FILE* fopen(const char*, const char*);
https://gcc.gnu.org/onlinedocs/gcc-11.3.0/gcc/Common-Function-Attributes.html#Common-Function-Attributes
I know but clang does not :-|
(Nominating this for SDL3.)
If the deallocation attribute make sense later, and doesn't need us to make drastic changes to support it, let's talk about that in a separate issue or PR.