debug assertion error dbgheap.c

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?REx1ZWNr?=

    debug assertion error dbgheap.c

    I am getting a debug assertion error that reads:

    Debug Assertion Failed!

    program E:\program files\internet explorer\iexplo re,exe
    File: dbgheap.c
    Line: 1252

    Expression: _CrtIsValidHeap Pointer(pUserDa ta)





    here is my code.

    // DEFINE VAIRABLES
    CString DataStream;
    int DataArray[11];
    int iCounter;
    string sBuffer;
    int pos;
    bool bDone;
    int m_count;
    int nStrPos;
    int nLength;
    int d = 0;
    CString MonitorCaption;
    bool GetMoreData = true;

    // initial log events variable
    if (LogInformation == "TRUE")
    {
    LogEvents = 0;
    }
    else
    {
    LogEvents = -1;
    }

    // set up interface pointer
    CPDSInterface* PDSInterface;

    if (PDSInterface != NULL)
    {
    PDSInterface = NULL;
    }

    // initialize variables for process
    DWORD Error = 0;

    if (PDSInterface != NULL)
    {
    PDSInterface = NULL;
    }

    PDSInterface = new CPDSInterface() ;

    // establishe iniital connect
    d = PDSInterface->Initialize("12 7.0.0.1");

    if (d != SUCCESS)
    {
    if (LogEvents == 0)
    {
    CString strMessage("Fai lured to initialize Monitor");
    ErrorLog(strMes sage);
    }
    return;
    }

    // need to open a connection to the gateway first..
    d = PDSInterface->Connect("196.7 6.0.1");

    if (d != SUCCESS)
    {
    if (LogEvents == 0)
    {
    CString strMessage("Fai lured to Connect to Monitor");
    ErrorLog(strMes sage);
    }
    return;
    }

    // clear the buffers
    d = PDSInterface->ClearData("196 .76.0.1");

    if (d != SUCCESS)
    {
    if (LogEvents == 0)
    {
    CString strMessage("Fai lured to clear the buffer of Monitor");
    ErrorLog(strMes sage);
    }
    return;
    }

    // udpdate caption of button
    MonitorCaption = m_Caption;
    COleControl::Se tText(MonitorCa ption);
    COleControl::Re drawWindow(0,0, RDW_UPDATENOW);

    // main loop
    try
    {
    while (GetMoreData)
    {
    Sleep(1000);
    DoEvents();

    if (LogEvents == 0)
    {
    CString strMessage("bef ore datastream");
    ErrorLog(strMes sage);
    }

    if (PDSInterface == NULL)
    {
    CString strMessage("PDS Interface is NULL.");
    CString strTitle("TITLE ");
    MessageBox(strM essage, strTitle, MB_OK);
    }

    // get data from monitor
    d = PDSInterface->GetData("196.7 6.0.1", DataStream);

    if (LogEvents == 0)
    {
    CString strMessage(Data Stream);
    ErrorLog(strMes sage);
    }

    if (DataStream == "")
    {
    CString strMessage("Dat aStream is NULL");
    ErrorLog(strMes sage);
    }

    Sleep(1000);
    DoEvents();

    if ((d == SUCCESS) && (DataStream != ""))
    {

    // reset variables
    m_count = 0;
    pos = 0;
    iCounter = 0;
    bDone = false;

    // convert cstring to string, to be able to work with the string
    properties
    CT2CA pszConvertedAns iString (DataStream);
    string sWorkString (pszConvertedAn siString);

    // parse data steam into data array
    pos = sWorkString.fin d(' ');

    if (LogEvents == 0)
    {
    CString strMessage("Bef ore Parsing");
    ErrorLog(strMes sage);
    }

    if (pos >= 0)
    {
    nLength = sWorkString.siz e();
    // we have work to do,and we have to do it one character at a time
    sBuffer = "";
    nStrPos = 0;

    do
    {
    char cCharToAdd = sWorkString.at( nStrPos);

    if (cCharToAdd != ' ')
    {
    //add the character
    sBuffer += cCharToAdd;
    nStrPos++;
    }
    else
    {
    if (sBuffer == "-32767")
    {
    DataArray[iCounter] = 0;
    }
    else
    {
    DataArray[iCounter] = atoi(sBuffer.c_ str());
    }
    iCounter++;
    nStrPos++;
    sBuffer = "";
    }

    if (nStrPos >= nLength)
    {
    bDone = true;

    }
    } while (!bDone);
    }

    if (LogEvents == 0)
    {
    CString strMessage("Aft er Parsing");
    ErrorLog(strMes sage);
    }

    // move data to variables
    int Systolic = DataArray[1];
    int Diastolic = DataArray[2];
    int ETCO2 = DataArray[5];
    int PulseRate = DataArray[6];
    int RespirationRate = DataArray[8];
    int SPO2 = DataArray[10];

    // Update Web Page
    UpdateWebPage(P ulseRate, Systolic, Diastolic, SPO2, RespirationRate );
    DoEvents();

    if (LogEvents == 0)
    {
    CString strMessage("aft er web update");
    ErrorLog(strMes sage);
    }

    Sleep(1000);
    DoEvents();


    // write to log
    WriteToLog(Puls eRate,Systolic, Diastolic,SPO2, RespirationRate );
    DoEvents();
    }
    if (LogEvents == 0)
    {
    CString strMessage("bef ore returning to top");
    ErrorLog(strMes sage);
    }
    }
    }

    // catch all errors
    catch(...)
    {
    GetMoreData = false;
    }
    return;

    please help,
Working...