コード例 #1
0
ファイル: XT.cpp プロジェクト: robessog/OBS
//note to self:  do try not to rely on this too much.
void __cdecl CrashError(const TCHAR *format, ...)
{
    if(!format) return;

    va_list arglist;

    va_start(arglist, format);

    String strOut = FormattedStringva(format, arglist);

    OpenLogFile();
    LogFile.WriteStr(TEXT("\r\nError: "));
    LogFile.WriteAsUTF8(strOut);
    LogFile.WriteStr(TEXT("\r\n"));
    CloseLogFile();

    OSMessageBoxva(format, arglist);

#if defined(_DEBUG) && defined(_WIN32)
    if(bDebugBreak && OSDebuggerPresent())
        ProgramBreak();
#endif

    CriticalExit();
}
コード例 #2
0
ファイル: DebugAlloc.cpp プロジェクト: Alucard014/OBS
void * __restrict DebugAlloc::_Allocate(size_t dwSize)
{
    if(!dwSize) return NULL;

    OSEnterMutex(hDebugMutex);

    LPVOID lpRet;

    if(bEnableTracking)
    {
        ++allocationCounter;
        ++totalAllocations;
    }

    if(bEnableTracking && allocationCounter == memoryBreakID)
        ProgramBreak();

    if((lpRet=FastAlloc::_Allocate(dwSize)) && bEnableTracking)
    {
        Allocation allocTemp;

        Allocation *new_array = (Allocation*)FastAlloc::_Allocate(sizeof(Allocation)*++numAllocations);
        zero(new_array, sizeof(Allocation)*numAllocations);


        allocTemp.Address = lpRet;
        if(lpAllocCurFile)
            scpy(allocTemp.lpFile, lpAllocCurFile);
        allocTemp.dwLine = dwAllocCurLine;

        if(bEnableTracking)
            allocTemp.allocationID = allocationCounter;
        else
            allocTemp.allocationID = INVALID;

        if(AllocationList)
            mcpy(new_array, AllocationList, sizeof(Allocation)*(numAllocations-1));

        FastAlloc::_Free(AllocationList);

        AllocationList = new_array;

        mcpy(&AllocationList[numAllocations-1], &allocTemp, sizeof(Allocation));
    }

    OSLeaveMutex(hDebugMutex);

    return lpRet;
}
コード例 #3
0
ファイル: DebugAlloc.cpp プロジェクト: Alucard014/OBS
void * DebugAlloc::_ReAllocate(LPVOID lpData, size_t dwSize)
{
    LPVOID lpRet;

    if(!lpData)
    {
        lpRet = _Allocate(dwSize);
        return lpRet;
    }

    OSEnterMutex(hDebugMutex);

    if(bEnableTracking)
    {
        ++allocationCounter;
        ++totalAllocations;
    }

    if(bEnableTracking && allocationCounter == memoryBreakID)
        ProgramBreak();

    lpRet = FastAlloc::_ReAllocate(lpData, dwSize);

    /*if(bEnableTracking)
    {*/
        for(DWORD i=0;i<numAllocations;i++)
        {
            if(AllocationList[i].Address == lpData)
            {
                if(bEnableTracking)
                    AllocationList[i].allocationID = allocationCounter;
                else
                    AllocationList[i].allocationID = INVALID;

                AllocationList[i].Address = lpRet;
                break;
            }
        }
    //}

    OSLeaveMutex(hDebugMutex);

    return lpRet;
}
コード例 #4
0
ファイル: Effect.new.cpp プロジェクト: alanzw/JimEngine
Effect::Effect(GraphicsSystem *curSystem, CTSTR lpEffectFile)
{
    traceIn(Effect::Effect);

    system = curSystem;

    String strEffectFile = lpEffectFile;
    strEffectFile.FindReplace(TEXT("\\"), TEXT("/"));
    strEffectDir = GetPathDirectory(strEffectFile);

    effectPath = strEffectFile;

    XFile chi;

    if(!chi.Open(strEffectFile, XFILE_READ, XFILE_OPENEXISTING))
        ErrOut(TEXT("Could not open effect file '%s'"), strEffectFile.Array());

    String strFile;
    chi.ReadFileToString(strFile);
    chi.Close();

    String errors;

    bProcessing = TRUE;
    system->curProcessingEffect = this;

    EffectProcessor test;
    if(!test.ProcessEffect(this, GetPathFileName(strEffectFile, TRUE), strFile, errors))
        ProgramBreak();

    bProcessing = FALSE;
    system->curProcessingEffect = NULL;

    hViewProj = GetParameterByName(TEXT("ViewProj"));
    hWorld = GetParameterByName(TEXT("World"));
    hScale = GetParameterByName(TEXT("World"));

    traceOut;
}
コード例 #5
0
void __cdecl AppWarning(const TCHAR *format, ...)
{
    if(!format) return;

    va_list arglist;

    va_start(arglist, format);

    String strOut(L"Warning -- ");
    strOut << FormattedStringva(format, arglist);

    if(bLogStarted)
    {
        OpenLogFile();
        LogFile.WriteAsUTF8(strOut, strOut.Length());
        LogFile.WriteAsUTF8(TEXT("\r\n"));
        CloseLogFile();
    }

    OSDebugOut(TEXT("Warning -- "));
    OSDebugOutva(format, arglist);
    OSDebugOut(TEXT("\r\n"));

    //------------------------------------------------------
    // NOTE:
    // If you're seeting this, you can safely continue running, but I recommend fixing whatever's causing this warning.
    //
    // The debug output window contains the warning that has occured.
    //------------------------------------------------------

#if defined(_DEBUG) && defined(_WIN32)
    if(bDebugBreak && OSDebuggerPresent())
    {
        ProgramBreak();
    }
#endif

    StringLog.Append(strOut);
}