summaryrefslogtreecommitdiff
path: root/libavutil/mem.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2017-03-20 08:52:07 +0100
committerClément Bœsch <u@pkh.me>2017-03-20 08:54:44 +0100
commit3835283293bfd38ba69203f4618f0f0f21377bcc (patch)
tree7b6ae566da1780f7b736250cb1cb90b97b8c1e0f /libavutil/mem.c
parenta5cf6628d68edd1c14d483e07bb5e68026eb707a (diff)
parent4fb311c804098d78e5ce5f527f9a9c37536d3a08 (diff)
Merge commit '4fb311c804098d78e5ce5f527f9a9c37536d3a08'
* commit '4fb311c804098d78e5ce5f527f9a9c37536d3a08': Drop memalign hack Merged, as this may indeed be uneeded since 46e3936fb04d06550151e667357065e3f646da1a. Merged-by: Clément Bœsch <u@pkh.me>
Diffstat (limited to 'libavutil/mem.c')
-rw-r--r--libavutil/mem.c36
1 files changed, 3 insertions, 33 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 1a8fc21e98..36740f1154 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -77,22 +77,12 @@ void av_max_alloc(size_t max){
void *av_malloc(size_t size)
{
void *ptr = NULL;
-#if CONFIG_MEMALIGN_HACK
- long diff;
-#endif
/* let's disallow possibly ambiguous cases */
if (size > (max_alloc_size - 32))
return NULL;
-#if CONFIG_MEMALIGN_HACK
- ptr = malloc(size + ALIGN);
- if (!ptr)
- return ptr;
- diff = ((~(long)ptr)&(ALIGN - 1)) + 1;
- ptr = (char *)ptr + diff;
- ((char *)ptr)[-1] = diff;
-#elif HAVE_POSIX_MEMALIGN
+#if HAVE_POSIX_MEMALIGN
if (size) //OS X on SDK 10.6 has a broken posix_memalign implementation
if (posix_memalign(&ptr, ALIGN, size))
ptr = NULL;
@@ -144,25 +134,11 @@ void *av_malloc(size_t size)
void *av_realloc(void *ptr, size_t size)
{
-#if CONFIG_MEMALIGN_HACK
- int diff;
-#endif
-
/* let's disallow possibly ambiguous cases */
if (size > (max_alloc_size - 32))
return NULL;
-#if CONFIG_MEMALIGN_HACK
- //FIXME this isn't aligned correctly, though it probably isn't needed
- if (!ptr)
- return av_malloc(size);
- diff = ((char *)ptr)[-1];
- av_assert0(diff>0 && diff<=ALIGN);
- ptr = realloc((char *)ptr - diff, size + diff);
- if (ptr)
- ptr = (char *)ptr + diff;
- return ptr;
-#elif HAVE_ALIGNED_MALLOC
+#if HAVE_ALIGNED_MALLOC
return _aligned_realloc(ptr, size + !size, ALIGN);
#else
return realloc(ptr, size + !size);
@@ -227,13 +203,7 @@ int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
void av_free(void *ptr)
{
-#if CONFIG_MEMALIGN_HACK
- if (ptr) {
- int v= ((char *)ptr)[-1];
- av_assert0(v>0 && v<=ALIGN);
- free((char *)ptr - v);
- }
-#elif HAVE_ALIGNED_MALLOC
+#if HAVE_ALIGNED_MALLOC
_aligned_free(ptr);
#else
free(ptr);