Commit 254e16a8 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Allocate aligned memory for block_sys_t

parent 67f66f79
......@@ -86,13 +86,18 @@ block_t *block_Alloc( size_t i_size )
{
/* We do only one malloc
* TODO: bench if doing 2 malloc but keeping a pool of buffer is better
* TODO: use memalign
* 16 -> align on 16
* 2 * BLOCK_PADDING_SIZE -> pre + post padding
*/
const size_t i_alloc = i_size + 2 * BLOCK_PADDING_SIZE + BLOCK_ALIGN;
block_sys_t *p_sys = malloc( sizeof( *p_sys ) + i_alloc );
block_sys_t *p_sys;
#ifdef HAVE_POSIX_MEMALIGN
p_sys = posix_memalign( &p_sys, BLOCK_ALIGN, sizeof( *p_sys ) + i_alloc ) ? NULL : p_sys;
#elif HAVE_MEMALIGN
p_sys = memalign( BLOCK_ALIGIN, sizeof( *p_sys ) + i_alloc );
#else
p_sys = malloc( sizeof( *p_sys ) + i_alloc );
#endif
if( p_sys == NULL )
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment