Commit 58f30175 authored by Michael Niedermayer's avatar Michael Niedermayer

mem: minor simplification of the alignment hack code

Idea-by: wanzhang
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent d1870624
...@@ -84,7 +84,7 @@ void *av_malloc(size_t size) ...@@ -84,7 +84,7 @@ void *av_malloc(size_t size)
ptr = malloc(size + ALIGN); ptr = malloc(size + ALIGN);
if (!ptr) if (!ptr)
return ptr; return ptr;
diff = ((-(long)ptr - 1)&(ALIGN - 1)) + 1; diff = ((~(long)ptr)&(ALIGN - 1)) + 1;
ptr = (char *)ptr + diff; ptr = (char *)ptr + diff;
((char *)ptr)[-1] = diff; ((char *)ptr)[-1] = diff;
#elif HAVE_POSIX_MEMALIGN #elif HAVE_POSIX_MEMALIGN
......
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