cpuinfo: Set padding to 0 if none is needed

It'll be simpler to use overflow detection after this refactor.

Signed-off-by: Simon McVittie <smcv@collabora.com>
main
Simon McVittie 2022-05-09 18:48:46 +01:00 committed by Sam Lantinga
parent d15f6e379c
commit cf1daafa3f
1 changed files with 4 additions and 4 deletions

View File

@ -1058,8 +1058,8 @@ void *
SDL_SIMDAlloc(const size_t len)
{
const size_t alignment = SDL_SIMDGetAlignment();
const size_t padding = alignment - (len % alignment);
const size_t padded = (padding != alignment) ? (len + padding) : len;
const size_t padding = (alignment - (len % alignment)) % alignment;
const size_t padded = len + padding;
Uint8 *retval = NULL;
Uint8 *ptr = (Uint8 *) SDL_malloc(padded + alignment + sizeof (void *));
if (ptr) {
@ -1075,8 +1075,8 @@ void *
SDL_SIMDRealloc(void *mem, const size_t len)
{
const size_t alignment = SDL_SIMDGetAlignment();
const size_t padding = alignment - (len % alignment);
const size_t padded = (padding != alignment) ? (len + padding) : len;
const size_t padding = (alignment - (len % alignment)) % alignment;
const size_t padded = len + padding;
Uint8 *retval = (Uint8*) mem;
void *oldmem = mem;
size_t memdiff = 0, ptrdiff;