_vorbis_block_alloc assumes _ogg_malloc aligns to at least WORD_ALIGN
To guarantee WORD_ALIGN alignment, you need to align the pointer after
calling _ogg_malloc(), or _ogg_realloc().
If you are doing cache tuning, you might want to push WORD_ALIGN fairly
high, like 16 or 32 depending on the cache architecture.
possible patch:
*** block.c 2002/03/29 07:34:09 1.64
--- block.c 2002/04/12 11:02:00
***************
*** 115,120 ****
--- 115,122 ----
/* highly conservative */
vb->localalloc=bytes;
vb->localstore=_ogg_malloc(vb->localalloc);
+ vb->localstore=(void*)(((long)((char*)vb->localstore+
+ (WORD_ALIGN-1))) & ~(WORD_ALIGN-1));
vb->localtop=0;
}
{
***************
*** 137,143 ****
}
/* consolidate storage */
if(vb->totaluse){
! vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->
localalloc);
vb->localalloc+=vb->totaluse;
vb->totaluse=0;
}
--- 139,148 ----
}
/* consolidate storage */
if(vb->totaluse){
! long tot=(vb->totaluse+vb->localalloc+(WORD_ALIGN-1)) &
~(WORD_ALIGN-1);
! vb->localstore=_ogg_realloc(vb->localstore,tot);
! vb->localstore=(void*)(((long)((char*)vb->localstore+
! (WORD_ALIGN-1))) & ~(WORD_ALIGN-1));
vb->localalloc+=vb->totaluse;
vb->totaluse=0;
}
It may be better to define a macro that does the alignment.