# HG changeset patch # User michael # Date 1086493553 0 # Node ID d07784fbdad1075835dde6cb0c0a44fb31c51287 # Parent ad972ab280bc9d2ccdb800373cc432c22e1ccd61 optional and disabled by default memalign hack for SSE/SSE2 on that alternative OS diff -r ad972ab280bc -r d07784fbdad1 mem.c --- a/mem.c Sat Jun 05 22:36:43 2004 +0000 +++ b/mem.c Sun Jun 06 03:45:53 2004 +0000 @@ -46,7 +46,13 @@ { void *ptr; -#if defined (HAVE_MEMALIGN) +#ifdef MEMALIGN_HACK + int diff; + ptr = malloc(size+16+1); + diff= ((-(int)ptr - 1)&15) + 1; + ptr += diff; + ((char*)ptr)[-1]= diff; +#elif defined (HAVE_MEMALIGN) ptr = memalign(16,size); /* Why 64? Indeed, we should align it: @@ -87,7 +93,13 @@ */ void *av_realloc(void *ptr, unsigned int size) { +#ifdef MEMALIGN_HACK + //FIXME this isnt aligned correctly though it probably isnt needed + int diff= ptr ? ((char*)ptr)[-1] : 0; + return realloc(ptr - diff, size + diff) + diff; +#else return realloc(ptr, size); +#endif } /* NOTE: ptr = NULL is explicetly allowed */ @@ -95,6 +107,10 @@ { /* XXX: this test should not be needed on most libcs */ if (ptr) +#ifdef MEMALIGN_HACK + free(ptr - ((char*)ptr)[-1]); +#else free(ptr); +#endif }