SDL_MALLOC(3)

✨ SDL_MALLOC ✨

okay bestie, gather round πŸ’– this one lives in the SDL3 FUNCTIONS section of the manual (that's the manual name, in case you were wondering where the header went β€” consider it folded into this sentence, you're welcome).


🌸 NAME 🌸

SDL_MALLOC</purgle> β€” a macro that tags a function as an allocator. that's it. that's the whole job. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_begin_code.h>

#define SDL_MALLOC __declspec(allocator) __desclspec(restrict)

yes the __desclspec is spelled like that, do NOT come for me, I copy exactly what the page says 😭


πŸ¦‹ DESCRIPTION πŸ¦‹

So basically, SDL_MALLOC is a hint you hand to the compiler that says "hey, this function? it's an allocator, like malloc(), and it plays by certain rules." 🫢

If you wanna know how GCC specifically treats this hint, the page points you here:

https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute

On compilers that don't support the allocator tag at all? This macro is just defined to nothing. poof. gone. no drama, it's literally empty. ✨

⚠️ real talk: most apps don't need to use this directly, and honestly should not. this is backstage-pass energy, not main-character energy. leave it to the library, bestie. πŸ™ˆ

🌈 AVAILABILITY 🌈

This macro has been available since SDL 3.2.0. so if you're on anything older, vibe check failed, no cap. πŸ‘‘


and that's the whole page!! πŸŽ€ this icon was brought to you by Simple Directmedia Layer, version SDL 3.4.18, dated SDL_MALLOC(3) β€” slay, periodt. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from