CSampleQueue memory deallocation



  • I have a code like below
    Where RB_ANALOGTOOL_MAXNUMCHANNELS = 18;

    cSampleQueue m_QueuesDig[RB_ANALOGTOOL_MAXNUMCHANNELS];

    for(int k=0; k<RB_ANALOGTOOL_MAXNUMCHANNELS; k++)
    {
    m_QueuesDig[k] = new cSampleQueue(0,-1);
    }

    for (int k=0; k<RB_ANALOGTOOL_MAXNUMCHANNELS; k++)
    {
    m_QueuesDig[k]->Clear();//line 3

    }*

    I want to know whether line 3 will deallocate the memory or just clear the data in each location.
    If it does not deallocate the memory let me know how it can be done.
    I am trying delete[] m_QueuesDig but getting violation."This may be due to a corruption of the heap,which indicates a bug in adtf_devenv.exe or any of the DLLs it has loaded".

    Can any one let me know some solution regarding above problem.



  • To be able to do that:
    @m_QueuesDig[k] = new cSampleQueue(0,-1);@

    you should define an array of pointers:
    @cSampleQueue *m_QueuesDig[RB_ANALOGTOOL_MAXNUMCHANNELS];@

    and then you'll be able to delete each one separately like this:
    @delete m_QueuesDig[k]@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.