SDL_aligned_alloc(3)
β¨ SDL_aligned_alloc(3) β¨
okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages, where we talk about SDL_aligned_alloc π
π NAME π
SDL_aligned_alloc β allocate memory aligned to a specific alignment. yes queen, we're doing alignment today π¦
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
void * SDL_aligned_alloc(size_t alignment, size_t size);
like. that's it. that's the whole vibe. go off π«Ά
π DESCRIPTION π
okay so real talk, the memory this function hands you? you must free it with SDL_aligned_free(), and not SDL_free(). not a drill. NOT SDL_free(). i'm literally begging you π that's the number one way people mess this up and it's giving chaos.
if alignment is smaller than the size of void *, it gets bumped up to match that. so it's never gonna be smaller than a pointer, no cap. lowkey a little self-care on its part β¨
and here's the cute part: the returned memory address will be a multiple of the alignment value, and the size of the memory allocated will also be a multiple of the alignment value. both. iconic behaviour fr fr π
π FUNCTION PARAMETERS π
alignmentβ the alignment of the memory. this is your moment, your main character number, the thing the address has to divide by evenly π«sizeβ the size to allocate. how much memory you want, bestie. your whole snack order π
β RETURN VALUE β
returns a pointer to the aligned memory, or NULL if allocation failed π
NULL means it didn't work. don't dereference it. don't be that girl. check your return values, periodt.
π§ THREAD SAFETY π§
it is safe to call this function from any thread. any of them. all of them. the whole group chat can show up at once and it's fine ππ₯
π AVAILABILITY π
this function is available since SDL 3.2.0. if you're on something older, sorry babes, it's not there yet π
π¦ SEE ALSO π¦
SDL_aligned_free(3)β the one you actually have to use to free this. the way that they're a matched setβ¦ obsessed π
and that's the whole page!! brought to you by Simple Directmedia Layer, version SDL 3.4.18 β mwah, slay, go allocate responsibly, ily, bye!! πβ¨πΈπ«Ά
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms