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

  Synopsis    [Adds a function to a hook.]

  Description [Adds a function to a hook. A hook is a list of
  application-provided functions called on certain occasions by the
  package. Returns 1 if the function is successfully added; 2 if the
  function was already in the list; 0 otherwise.]

  SideEffects [None]

  SeeAlso     [Cudd_RemoveHook]

******************************************************************************/
Function
Synopsis    [Adds a function to a hook.]

Description [Adds a function to a hook. A hook is a list of
application-provided functions called on certain occasions by the
package. Returns 1 if the function is successfully added; 2 if the
function was already in the list; 0 otherwise.]




Function Synopsis [ Adds a function to a hook . ] Description [ Adds a function to a hook . A hook is a list of application - provided functions called on certain occasions by the package . Returns 1 if the function is successfully added ; 2 if the function was already in the list ; 0 otherwise . ]
int
Cudd_AddHook(
  DdManager * dd,
  DD_HFP f,
  Cudd_HookType where)
{
    DdHook **hook, *nextHook, *newHook;
    switch (where) {
    case CUDD_PRE_GC_HOOK:
        hook = &(dd->preGCHook);
        break;
    case CUDD_POST_GC_HOOK:
        hook = &(dd->postGCHook);
        break;
    case CUDD_PRE_REORDERING_HOOK:
        hook = &(dd->preReorderingHook);
        break;
    case CUDD_POST_REORDERING_HOOK:
        hook = &(dd->postReorderingHook);
        break;
    default:
        return(0);
    }
    nextHook = *hook;
    while (nextHook != NULL) {
        if (nextHook->f == f) {
            return(2);
        }
        hook = &(nextHook->next);
        nextHook = nextHook->next;
    }
    newHook = ABC_ALLOC(DdHook,1);
    if (newHook == NULL) {
        dd->errorCode = CUDD_MEMORY_OUT;
        return(0);
    }
    newHook->next = NULL;
    newHook->f = f;
    *hook = newHook;
    return(1);
}
int Cudd_AddHook ( DdManager * dd , DD_HFP f , Cudd_HookType where ) { DdHook * * hook , * nextHook , * newHook ; switch ( where ) { case CUDD_PRE_GC_HOOK : hook = & ( dd -> preGCHook ) ; break ; case CUDD_POST_GC_HOOK : hook = & ( dd -> postGCHook ) ; break ; case CUDD_PRE_REORDERING_HOOK : hook = & ( dd -> preReorderingHook ) ; break ; case CUDD_POST_REORDERING_HOOK : hook = & ( dd -> postReorderingHook ) ; break ; default : return ( 0 ) ; } nextHook = * hook ; while ( nextHook != NULL ) { if ( nextHook -> f == f ) { return ( 2 ) ; } hook = & ( nextHook -> next ) ; nextHook = nextHook -> next ; } newHook = ABC_ALLOC ( DdHook , 1 ) ; if ( newHook == NULL ) { dd -> errorCode = CUDD_MEMORY_OUT ; return ( 0 ) ; } newHook -> next = NULL ; newHook -> f = f ; * hook = newHook ; return ( 1 ) ; }
Function
Synopsis    [Adds a function to a hook.]
Function Synopsis [ Adds a function to a hook . ]
/* Scan the list and find whether the function is already there.
    ** If so, just return. */ /* The function was not in the list. Create a new item and append it
    ** to the end of the list. */