Ejemplo n.º 1
0
void CrstBase::DebugDestroy()
{
    FillMemory(&m_criticalsection, sizeof(m_criticalsection), 0xcc);
    m_holderthreadid = 0xcccccccc;
    m_entercount     = 0xcccccccc;
    
    if (this == &m_DummyHeadCrst) {
        
        // m_DummyHeadCrst dies when global destructors are called.
        // It should be the last one to go.
        for (CrstBase *pcrst = m_pDummyHeadCrst->m_next;
             pcrst != m_pDummyHeadCrst;
             pcrst = pcrst->m_next) {
            // TEXT and not L"..." as the JIT uses this file and it is still ASCII
            DbgWriteEx(TEXT("WARNING: Crst \"%hs\" at 0x%lx was leaked.\n"),
                       pcrst->m_tag,
                       (size_t)pcrst);
        }
    } else {
        
        if(m_pDummyHeadCrst) {
        // Unlink from global crst list.
        LOCKCOUNTINCL("DebugDestroy in crst.cpp");								\
            EnterCriticalSection(&(m_pDummyHeadCrst->m_criticalsection));
            m_next->m_prev = m_prev;
            m_prev->m_next = m_next;
            m_next = (CrstBase*)POISONC;
            m_prev = (CrstBase*)POISONC;
            LeaveCriticalSection(&(m_pDummyHeadCrst->m_criticalsection));
        LOCKCOUNTDECL("DebugDestroy in crst.cpp");								\
        }
    }
}
Ejemplo n.º 2
0
//*****************************************************************************
// This function is called in order to ultimately return an out of memory
// failed hresult.  But this guy will check what environment you are running
// in and give an assert for running in a debug build environment.  Usually
// out of memory on a dev machine is a bogus alloction, and this allows you
// to catch such errors.  But when run in a stress envrionment where you are
// trying to get out of memory, assert behavior stops the tests.
//*****************************************************************************
HRESULT _OutOfMemory(LPCSTR szFile, int iLine)
{
    STATIC_CONTRACT_NOTHROW;
    STATIC_CONTRACT_GC_NOTRIGGER;
    STATIC_CONTRACT_DEBUG_ONLY;

    DbgWriteEx(W("WARNING:  Out of memory condition being issued from: %hs, line %d\n"),
            szFile, iLine);
    return (E_OUTOFMEMORY);
}
Ejemplo n.º 3
0
void FreeMemory(void *pbData)
{
#if defined(_DEBUG) && defined(_TRACE_MEM_)
    static int i=0;
    DbgWriteEx(W("FreeMemory: (%d) 0x%08x\n"), ++i, pbData);
#endif

    _ASSERTE(pbData);
    delete [] (BYTE *) pbData;
}
Ejemplo n.º 4
0
void *AllocateMemory(int iSize)
{
    void * ptr;
    ptr = new (nothrow) BYTE[iSize];

#if defined(_DEBUG) && defined(_TRACE_MEM_)
    static int i=0;
    DbgWriteEx(W("AllocateMemory: (%d) 0x%08x, size %d\n"), ++i, ptr, iSize);
#endif
    return (ptr);
}
Ejemplo n.º 5
0
//*****************************************************************************
// This function is called in order to ultimately return an out of memory
// failed hresult.  But this guy will check what environment you are running
// in and give an assert for running in a debug build environment.  Usually
// out of memory on a dev machine is a bogus alloction, and this allows you
// to catch such errors.  But when run in a stress envrionment where you are
// trying to get out of memory, assert behavior stops the tests.
//*****************************************************************************
HRESULT _OutOfMemory(LPCSTR szFile, int iLine)
{
    DbgWriteEx(L"WARNING:  Out of memory condition being issued from: %hs, line %d\n",
            szFile, iLine);
    return (E_OUTOFMEMORY);
}