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.
I want to know whether line 3 will ...

You don't have line numbers, so I don't which line you have in mind.

There's nothing in your code that implies deallocation.

As you're using C++ (and not C), why not use a standard collection?
1
2
3
4
5
6
7
8
typedef std::vector<CSampleQueue*> QueueType;

QueueType m_QueuesDlg;
for (int k = 0; k < RB_ANALOGTOOL_MAXNUMCHANNELS; ++k)
    m_QueuesDig.push_back(new cSampleQueue(0,-1));

for (auto p in m_QueuesDig)
    p->Clear();
It's look like same what i have implement .
Tell me one thing what p->clear() will do.
You haven't shown us the definition of cSampleQueue so how can we possibly know what that method will do?
Topic archived. No new replies allowed.