SDL_memcpy(3)
π SDL_memcpy β SDL3 FUNCTIONS π
okay bestie, gather round, because we're about to talk about the most "copy and paste but make it C" function in the whole SDL3 lineup π«Ά
β¨ NAME β¨
SDL_memcpy β copy non-overlapping memory. that's it. that's the whole job. she copies bytes and she does NOT want drama π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
void * SDL_memcpy(void *dst, const void *src, size_t len);
π¦ DESCRIPTION π¦
so here's the tea, and it is IMPORTANT tea: the memory regions must not overlap. like, at all. not even a little. if they do overlap, do not pass go, do not collect $200 β go use SDL_memmove() instead, because she was literally built for that π
lowkey a vibe check: overlapping +SDL_memcpy= undefined behaviour territory.SDL_memmove()is your girl for that situation, fr fr.
π FUNCTION PARAMETERS π
dstβ the destination memory region. she must not beNULL, and she must not overlap withsrc. boundaries, queen πsrcβ the source memory region. same rules, bestie: must not beNULL, and must not overlap withdst.lenβ the length in bytes of bothdstandsrc. one number, two regions, equal treatment, we love to see it β¨
π RETURN VALUE π
returns dst. that's it. she gives you back exactly what you handed her. iconic behaviour honestly π
π THREAD SAFETY π
it is safe to call this function from any thread. go wild, multi-threaded besties, she's not gonna snitch π§
β AVAILABILITY β
this function is available since SDL 3.2.0. so if you're on something olderβ¦ girl. upgrade π
π SEE ALSO π
SDL_memmove(3)β the overlapping-safe sister. when in doubt, she's the one you text π«Ά
and that's the whole page, bestie!! this lil masterpiece came to you courtesy of Simple Directmedia Layer, version SDL 3.4.18 π now go copy some non-overlapping bytes and slay β¨ππ¦
π¦ 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