mirror of https://github.com/YosysHQ/abc.git
Merge pull request #519 from heshpdx/master
Fix strict aliasing violations
This commit is contained in:
commit
3ce53c361f
|
|
@ -233,7 +233,7 @@ static inline Hop_Obj_t * Hop_ManFetchMemory( Hop_Man_t * p )
|
|||
if ( p->pListFree == NULL )
|
||||
Hop_ManAddMemory( p );
|
||||
pTemp = p->pListFree;
|
||||
p->pListFree = *((Hop_Obj_t **)pTemp);
|
||||
memcpy(&p->pListFree, pTemp, sizeof(Hop_Obj_t *));
|
||||
memset( pTemp, 0, sizeof(Hop_Obj_t) );
|
||||
if ( p->vObjs )
|
||||
{
|
||||
|
|
@ -245,8 +245,8 @@ static inline Hop_Obj_t * Hop_ManFetchMemory( Hop_Man_t * p )
|
|||
}
|
||||
static inline void Hop_ManRecycleMemory( Hop_Man_t * p, Hop_Obj_t * pEntry )
|
||||
{
|
||||
pEntry->Type = AIG_NONE; // distinquishes dead node from live node
|
||||
*((Hop_Obj_t **)pEntry) = p->pListFree;
|
||||
pEntry->Type = AIG_NONE; // distinguishes dead node from live node
|
||||
memcpy(pEntry, &p->pListFree, sizeof(Hop_Obj_t *));
|
||||
p->pListFree = pEntry;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,13 +88,15 @@ void Hop_ManStopMemory( Hop_Man_t * p )
|
|||
***********************************************************************/
|
||||
void Hop_ManAddMemory( Hop_Man_t * p )
|
||||
{
|
||||
char * pMemory;
|
||||
char * pMemory = 0;
|
||||
Hop_Obj_t * pEntry, * pNext;
|
||||
int i, nBytes;
|
||||
assert( sizeof(Hop_Obj_t) <= 64 );
|
||||
assert( p->pListFree == NULL );
|
||||
// assert( (Hop_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
|
||||
// allocate new memory page
|
||||
nBytes = sizeof(Hop_Obj_t) * (1<<IVY_PAGE_SIZE) + 64;
|
||||
pMemory = pMemory + 64 - (((int)(ABC_PTRUINT_T)pMemory) & 63);
|
||||
pMemory = ABC_ALLOC( char, nBytes );
|
||||
Vec_PtrPush( p->vChunks, pMemory );
|
||||
// align memory at the 32-byte boundary
|
||||
|
|
@ -102,13 +104,16 @@ void Hop_ManAddMemory( Hop_Man_t * p )
|
|||
// remember the manager in the first entry
|
||||
Vec_PtrPush( p->vPages, pMemory );
|
||||
// break the memory down into nodes
|
||||
p->pListFree = (Hop_Obj_t *)pMemory;
|
||||
pEntry = (Hop_Obj_t *)pMemory;
|
||||
p->pListFree = pEntry;
|
||||
for ( i = 1; i <= IVY_PAGE_MASK; i++ )
|
||||
{
|
||||
*((char **)pMemory) = pMemory + sizeof(Hop_Obj_t);
|
||||
pMemory += sizeof(Hop_Obj_t);
|
||||
pNext = pEntry + 1;
|
||||
memcpy( pEntry, &pNext, sizeof(Hop_Obj_t *) );
|
||||
pEntry++;
|
||||
}
|
||||
*((char **)pMemory) = NULL;
|
||||
pNext = NULL;
|
||||
memcpy( pEntry, &pNext, sizeof(Hop_Obj_t *) );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Reference in New Issue