The following code is available in cbufferpool:
For (I = 0; I <dwpoolsize; I ++)
{
Pbuffer = new cbuffer (
This,
M_dwbufferallocatedlength,
PHR
);
Omitting the error check code ......
Pbuffer-> inserthead (& m_buffers );
}
Assign dwpoolsize buffers to the buffer pool to generate dwpoolsize cbuffer object pointers. Of course, dwpoolsize cbuffer: m_listentry is also generated.
Pbuffer is cbuffer type
Called here
Void inserthead (in list_entry * plisthead) {assert (islistempty (& m_listentry); insertheadlist (plisthead, & m_listentry );}
Pbuffer-> inserthead (& m_buffers); [inserts the m_listentry in the new cbuffer into the cbufferpool member variable m_buffers in sequence to form a two-way linked list containing dwpoolsize + 1 element.
Call cbuffer * cbufferpool: getbuffer when the buffer to be deleted
The Code is as follows:
{
Cbuffer * pbuffer;
........
Plistentry = m_buffers.flink;
Pbuffer = cbuffer: recovercbuffer (plistentry );
// Use containing_record internally to obtain the cbuffer object of plistentry
...........
}