Revision 08675bb3 libavutil/mem.c

View differences:

libavutil/mem.c
57 57

  
58 58
#endif /* MALLOC_PREFIX */
59 59

  
60
#define ALIGN (HAVE_AVX ? 32 : 16)
61

  
60 62
/* You can redefine av_malloc and av_free in your project to use your
61 63
   memory allocator. You do not need to suppress this file because the
62 64
   linker will do it automatically. */
......
73 75
        return NULL;
74 76

  
75 77
#if CONFIG_MEMALIGN_HACK
76
    ptr = malloc(size+32);
78
    ptr = malloc(size+ALIGN);
77 79
    if(!ptr)
78 80
        return ptr;
79
    diff= ((-(long)ptr - 1)&31) + 1;
81
    diff= ((-(long)ptr - 1)&(ALIGN-1)) + 1;
80 82
    ptr = (char*)ptr + diff;
81 83
    ((char*)ptr)[-1]= diff;
82 84
#elif HAVE_POSIX_MEMALIGN
83
    if (posix_memalign(&ptr,32,size))
85
    if (posix_memalign(&ptr,ALIGN,size))
84 86
        ptr = NULL;
85 87
#elif HAVE_MEMALIGN
86
    ptr = memalign(32,size);
88
    ptr = memalign(ALIGN,size);
87 89
    /* Why 64?
88 90
       Indeed, we should align it:
89 91
         on 4 for 386

Also available in: Unified diff