Commit 06c9784a authored by Rafaël Carré's avatar Rafaël Carré

vlc_memalign(): osx 10.5 doesn't have posix_memalign()

parent 3388e6b0
...@@ -886,10 +886,34 @@ static inline void SetQWLE (void *p, uint64_t qw) ...@@ -886,10 +886,34 @@ static inline void SetQWLE (void *p, uint64_t qw)
VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t ); VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t );
/* Aligned memory allocator */ /* Aligned memory allocator */
#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif
#ifdef WIN32 #ifdef WIN32
# include <malloc.h> # include <malloc.h>
# define vlc_memalign(align, size) (__mingw_aligned_malloc(size, align)) # define vlc_memalign(align, size) (__mingw_aligned_malloc(size, align))
# define vlc_free(base) (__mingw_aligned_free(base)) # define vlc_free(base) (__mingw_aligned_free(base))
#elif defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
static inline void *vlc_memalign(size_t align, size_t size)
{
long diff;
void *ptr;
ptr = malloc(size+align);
if(!ptr)
return ptr;
diff = ((-(long)ptr - 1)&(align-1)) + 1;
ptr = (char*)ptr + diff;
((char*)ptr)[-1]= diff;
return ptr;
}
static void vlc_free(void *ptr)
{
if (ptr)
free((char*)ptr - ((char*)ptr)[-1]);
}
#else #else
static inline void *vlc_memalign(size_t align, size_t size) static inline void *vlc_memalign(size_t align, size_t size)
{ {
......
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