Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
Vorbis
Vorbis
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Xiph.Org
  • VorbisVorbis
  • Issues
  • #182

Closed
Open
Opened Apr 12, 2002 by Gitlab Bot@GitlabBotDeveloper

_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.
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: xiph/vorbis#182