MCPcopy Create free account
hub / github.com/DentonW/DevIL / vec_malloc

Function vec_malloc

DevIL/src-IL/src/il_alloc.cpp:43–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41/*** Vector Allocation/Deallocation Function ***/
42#ifdef VECTORMEM
43void *vec_malloc(const ILsizei size)
44{
45 const ILsizei _size = size % 16 > 0 ? size + 16 - (size % 16) : size; // align size value
46
47#ifdef MM_MALLOC
48 return _mm_malloc(_size,16);
49#else
50#ifdef VALLOC
51 return valloc( _size );
52#else
53#ifdef POSIX_MEMALIGN
54 char *buffer;
55 return posix_memalign((void**)&buffer, 16, _size) == 0 ? buffer : NULL;
56#else
57#ifdef MEMALIGN
58 return memalign( 16, _size );
59#else
60 // Memalign hack from ffmpeg for MinGW
61 void *ptr;
62 int diff;
63 ptr = malloc(_size+16+1);
64 diff= ((-(int)ptr - 1)&15) + 1;
65 ptr = (void*)(((char*)ptr)+diff);
66 ((char*)ptr)[-1]= diff;
67 return ptr;
68#endif //MEMALIGN
69#endif //POSIX_MEMALIGN
70#endif //VALLOC
71#endif //MM_MALLOC
72}
73
74void *ivec_align_buffer(void *buffer, const ILsizei size)
75{

Callers 2

ivec_align_bufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected