Added SDL_copyp to avoid size mismatch when copying values (thanks @1bsyl!)

Closes https://github.com/libsdl-org/SDL/pull/5811
This commit is contained in:
Sam Lantinga 2022-06-17 10:22:28 -07:00
parent b0e827fb65
commit adc6875870
18 changed files with 49 additions and 44 deletions

View file

@ -501,6 +501,11 @@ extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c,
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
#define SDL_copyp(dst, src) \
{ SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \
SDL_memcpy((dst), (src), sizeof (*(src)))
/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */
SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
{