MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDL_SIMDAlloc

Function SDL_SIMDAlloc

deps/SDL2/src/cpuinfo/SDL_cpuinfo.c:942–957  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

940}
941
942void *
943SDL_SIMDAlloc(const size_t len)
944{
945 const size_t alignment = SDL_SIMDGetAlignment();
946 const size_t padding = alignment - (len % alignment);
947 const size_t padded = (padding != alignment) ? (len + padding) : len;
948 Uint8 *retval = NULL;
949 Uint8 *ptr = (Uint8 *) SDL_malloc(padded + alignment + sizeof (void *));
950 if (ptr) {
951 /* store the actual malloc pointer right before our aligned pointer. */
952 retval = ptr + sizeof (void *);
953 retval += alignment - (((size_t) retval) % alignment);
954 *(((void **) retval) - 1) = ptr;
955 }
956 return retval;
957}
958
959void
960SDL_SIMDFree(void *ptr)

Callers 3

UnRLEAlphaFunction · 0.85
SDL_UnRLESurfaceFunction · 0.85

Calls 2

SDL_SIMDGetAlignmentFunction · 0.85
SDL_mallocFunction · 0.85

Tested by

no test coverage detected