I have a queue that defined as
queue<CData*> queue1;
In which class CData is
typedef unsigned char U8;
typedef unsigned int U32;
class CData
{
private:
U8* m_Data;
U32 m_Len;
public:
CData(void) : m_Data(NULL), m_Len(0)
{
}
~CData(void)
{
FreeData();
}
void FreeData()
{
if (m_Data)
{
delete[] m_Data;
m_Data = NULL;
}
}
};
I assume that my queue1 is initialized values as the bellow code
for (U32 k = 0; k<5; k++)
{
size_t data_size = 1;
U8 *data_buf = new U8[data_size];
for (size_t i = 0; i < data_size; ++i)
{
data_buf[i] = k;
}
CData* result = new CData(data_buf, data_size);
queue1.push(result);
delete[] data_buf;
data_buf = NULL;
}
Now, my queue1 will contain the value
0 1 2 3 4
My question is that how can I insert 3 number of zero values at the beginning of the queue1, so that the result will be
0 0 0 0 1 2 3 4
Second, How can i free/delete queue1 , after the application done. And if I used
CData* result = new CData();
How can I delete result
variable? I am using C++ in Ubuntu. Thanks in advance.