void* MallocAlign16(size_t size)
{
int ptrSize = sizeof(void*);
byte* ptr =(byte*) malloc(size + 16 + ptrSize);
byte* alignedPtr = (byte*) ( ((size_t) ptr) + 15 & ~15);
if( (alignedPtr - ptr) < ptrSize)
{
alignedPtr += 16;
}
*((size_t*) (alignedPtr - ptrSize)) = (size_t) ptr;
return (void*) alignedPtr;
}
void FreeAlign16(void* ptr)
{
int ptrSize = sizeof(void*);
free( (void *) *((size_t *) (( (byte *) ptr ) - ptrSize)) );
}