abc/src/bdd/cudd/cuddZddLin.c
/**Function********************************************************************

  Synopsis    [Given a set of moves, returns the ZDD heap to the order
  in effect before the moves.]

  Description [Given a set of moves, returns the ZDD heap to the
  order in effect before the moves.  Returns 1 in case of success;
  0 otherwise.]

  SideEffects [None]

******************************************************************************/
Function
Synopsis    [Given a set of moves, returns the ZDD heap to the order
in effect before the moves.]

Description [Given a set of moves, returns the ZDD heap to the
order in effect before the moves.  Returns 1 in case of success;
0 otherwise.]


Function Synopsis [ Given a set of moves returns the ZDD heap to the order in effect before the moves . ] Description [ Given a set of moves returns the ZDD heap to the order in effect before the moves . Returns 1 in case of success ; 0 otherwise . ]
static Move*
cuddZddUndoMoves(
  DdManager * table,
  Move * moves)
{
    Move *invmoves = NULL;
    Move *move;
    Move *invmove;
    int size;
    for (move = moves; move != NULL; move = move->next) {
        invmove = (Move *) cuddDynamicAllocNode(table);
        if (invmove == NULL) goto cuddZddUndoMovesOutOfMem;
        invmove->x = move->x;
        invmove->y = move->y;
        invmove->next = invmoves;
        invmoves = invmove;
        if (move->flags == CUDD_SWAP_MOVE) {
            invmove->flags = CUDD_SWAP_MOVE;
            size = cuddZddSwapInPlace(table,(int)move->x,(int)move->y);
            if (!size) goto cuddZddUndoMovesOutOfMem;
        } else if (move->flags == CUDD_LINEAR_TRANSFORM_MOVE) {
            invmove->flags = CUDD_INVERSE_TRANSFORM_MOVE;
            size = cuddZddLinearInPlace(table,(int)move->x,(int)move->y);
            if (!size) goto cuddZddUndoMovesOutOfMem;
            size = cuddZddSwapInPlace(table,(int)move->x,(int)move->y);
            if (!size) goto cuddZddUndoMovesOutOfMem;
        } else { 
#ifdef DD_DEBUG
            (void) fprintf(table->err,"Unforseen event in ddUndoMoves!\n");
#endif
            invmove->flags = CUDD_LINEAR_TRANSFORM_MOVE;
            size = cuddZddSwapInPlace(table,(int)move->x,(int)move->y);
            if (!size) goto cuddZddUndoMovesOutOfMem;
            size = cuddZddLinearInPlace(table,(int)move->x,(int)move->y);
            if (!size) goto cuddZddUndoMovesOutOfMem;
        }
        invmove->size = size;
    }
    return(invmoves);
cuddZddUndoMovesOutOfMem:
    while (invmoves != NULL) {
        move = invmoves->next;
        cuddDeallocMove(table, invmoves);
        invmoves = move;
    }
    return((Move *) CUDD_OUT_OF_MEM);
}
static Move * cuddZddUndoMoves ( DdManager * table , Move * moves ) { Move * invmoves = NULL ; Move * move ; Move * invmove ; int size ; for ( move = moves ; move != NULL ; move = move -> next ) { invmove = ( Move * ) cuddDynamicAllocNode ( table ) ; if ( invmove == NULL ) goto cuddZddUndoMovesOutOfMem ; invmove -> x = move -> x ; invmove -> y = move -> y ; invmove -> next = invmoves ; invmoves = invmove ; if ( move -> flags == CUDD_SWAP_MOVE ) { invmove -> flags = CUDD_SWAP_MOVE ; size = cuddZddSwapInPlace ( table , ( int ) move -> x , ( int ) move -> y ) ; if ( ! size ) goto cuddZddUndoMovesOutOfMem ; } else if ( move -> flags == CUDD_LINEAR_TRANSFORM_MOVE ) { invmove -> flags = CUDD_INVERSE_TRANSFORM_MOVE ; size = cuddZddLinearInPlace ( table , ( int ) move -> x , ( int ) move -> y ) ; if ( ! size ) goto cuddZddUndoMovesOutOfMem ; size = cuddZddSwapInPlace ( table , ( int ) move -> x , ( int ) move -> y ) ; if ( ! size ) goto cuddZddUndoMovesOutOfMem ; } else { #ifdef DD_DEBUG ( void ) fprintf ( table -> err , " \n " ) ; #endif invmove -> flags = CUDD_LINEAR_TRANSFORM_MOVE ; size = cuddZddSwapInPlace ( table , ( int ) move -> x , ( int ) move -> y ) ; if ( ! size ) goto cuddZddUndoMovesOutOfMem ; size = cuddZddLinearInPlace ( table , ( int ) move -> x , ( int ) move -> y ) ; if ( ! size ) goto cuddZddUndoMovesOutOfMem ; } invmove -> size = size ; } return ( invmoves ) ; cuddZddUndoMovesOutOfMem : while ( invmoves != NULL ) { move = invmoves -> next ; cuddDeallocMove ( table , invmoves ) ; invmoves = move ; } return ( ( Move * ) CUDD_OUT_OF_MEM ) ; }
Function
Synopsis    [Given a set of moves, returns the ZDD heap to the order
in effect before the moves.]
Function Synopsis [ Given a set of moves returns the ZDD heap to the order in effect before the moves . ]
/* must be CUDD_INVERSE_TRANSFORM_MOVE */