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
parent
d15f6e379c
commit
cf1daafa3f
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue