示例#1
0
/*
 *  ======== IRESMAN_HDVICP_exit ========
 *  Function called when RESMAN is no longer needed. Use it to free memory
 *  allocated etc
 */
IRES_Status IRESMAN_HDVICP_exit()
{
    Log_print0(Diags_ENTRY, "[+E] IRESMAN_HDVICP_exit> Enter");

    if (!(_initialized)) {
        Log_print0(Diags_EXIT,
                "[+X] IRESMAN_HDVICP_exit> Exit (status=IRES_ENOINIT)");

        return (IRES_ENOINIT);
    }

#ifdef xdc_target__os_Linux
    if (gate) {
        OsalSupport_deleteGate(gate);
        gate = NULL;
    }
#endif

    /* Set the initialized flag to zero again */
    _initialized = 0;

    _resmanInternalState->numOpens--;

    freeInternalState();

    Log_print0(Diags_EXIT, "[+X] IRESMAN_HDVICP_exit> Exit (status=IRES_OK)");

    return (IRES_OK);
}
/*
 *  ======== RMAN_exit ========
 *  Exit the generic IRES RMAN and free the memory back to the Memory manager
 *  using which it was created.
 */
IRES_Status RMAN_exit()
{
    IArg        key;
    Int         i;
    IRES_Status status = IRES_OK;


    if (rmanInit == 0) {
        return (IRES_ENOINIT);
    }

    Log_print0(Diags_ENTRY, "[+E] RMAN_exit> Enter ");

    rmanInternalState->info.refCount--;

    if (--rmanInit == 0) {
        if (initStatus != IRES_OK) {
            Log_print0(Diags_USER7, "[+7] RMAN_exit> RMAN_init call didn't "
                    "happen successfully. RMAN_exit will not unregister "
                    "any resources.");
            status = IRES_ENOINIT;
        }
        else {
            key = IGateProvider_enter(gate);

            Log_print1(Diags_EXIT, "[+X] RMAN_exit> tableIndex = %d",
                    (IArg)(resTable.tableIndex));

            /* Unregister the entries */
            Log_print0(Diags_EXIT, "[+X] RMAN_exit> Unregistering resources");

            for (i = 0; i < resTable.tableIndex; i++) {
                if (RMAN_TABLE[i] != NULL) {

                    /* Even if there is an error, unregister the rest */
                    if ((status = RMAN_TABLE[i]->exit()) != IRES_OK) {
                        Log_print2(Diags_USER7, "[+7] RMAN_exit> Error "
                                "unregistering the IRESMAN implementation "
                                "0x%x, status = %d",
                                (IArg)(RMAN_TABLE[i]), (IArg)status);
                        status = IRES_EFAIL;
                    }
                }
            }
            /* Free the RMAN object */
            freeInternalState();

            initStatus = IRES_ENOINIT;

            /* Free the gate after leaving it */
            IGateProvider_leave(gate, key);
            OsalSupport_deleteGate(gate);
            gate = NULL;
        }
    }

    Log_print1(Diags_EXIT, "[+X] RMAN_exit> Exit (status=%d)", (IArg)status);

    return (status);
}