<hr>
Class implementing a simple dynamic buffer, using heap memory functions. The buffer is dynamically resized as data is added. This class is thread safe using CriticalSection Objects. The heap is a newly created heap so it is not restricted by the PE header size limits.
Methods:
::Add()
Use this to add data to the end of buffer. It will automatically resize itself.
::Insert()
Insert data into the buffer. Buffer will dynamically resize.
::Remove()
Remove data from the buffer. Buffer will dynamically resize.
::Replace()
Replace exising data in the buffer with new data. The Buffer will dynamically resize if new data is larger than its replacing.
::ChangeSize()
Manually change the size of the buffer.
::Reset()
Clear the buffer and release the memory.
::GetSize()
Get the size of the buffer.
::GetPointer()
Get a pointer to the data in the buffer.
::Find()
Find specific data in the buffer.
::Lock()
::UnLock()
Prevent other threads from accessing the functions.
Sample Usage:
Code:
CvBuffer mbuf;
DWORD pos;
mbuf.Add("Hello My Name Is Rich.",-1);
printf("%sn",(char*)mbuf.GetPointer());
pos = mbuf.Find(0,"Is",-1,0);
mbuf.Replace(pos,2,"WAS",-1);
printf("%sn",(char*)mbuf.GetPointer());
DWORD pos;
mbuf.Add("Hello My Name Is Rich.",-1);
printf("%sn",(char*)mbuf.GetPointer());
pos = mbuf.Find(0,"Is",-1,0);
mbuf.Replace(pos,2,"WAS",-1);
printf("%sn",(char*)mbuf.GetPointer());
This will produce the output:-
Hello My Name Is Rich.
Hello My Name WAS Rich.
This example showed the use of strings but the same applies for any type of data.












