A large contiguous buffer allocated on the heap with new[]. More...
#include <llbuffer.h>
Public Member Functions | |
S32 | bytesLeft () const |
Get the number of bytes left in the buffer. | |
virtual S32 | capacity () const |
Return the current number of bytes allocated. | |
virtual bool | containsSegment (const LLSegment &segment) const |
Test if a segment is inside this buffer. | |
virtual bool | createSegment (S32 channel, S32 size, LLSegment &segment) |
Generate a segment for this buffer. | |
LLHeapBuffer (const U8 *src, S32 len) | |
Construct a heap buffer of minimum size len, and copy from src. | |
LLHeapBuffer (S32 size) | |
Construct a heap buffer with a specified size. | |
LLHeapBuffer () | |
Construct a heap buffer with a reasonable default size. | |
virtual bool | reclaimSegment (const LLSegment &segment) |
reclaim a segment from this buffer. | |
virtual | ~LLHeapBuffer () |
Simple destruction. |
A large contiguous buffer allocated on the heap with new[].
This class is a simple buffer implementation which allocates chunks off the heap. Once a buffer is constructed, it's buffer has a fixed length.
LLHeapBuffer::LLHeapBuffer | ( | ) |
Construct a heap buffer with a reasonable default size.
LLHeapBuffer::LLHeapBuffer | ( | S32 | size | ) | [explicit] |
Construct a heap buffer with a specified size.
size | The minimum size of the buffer. |
LLHeapBuffer::LLHeapBuffer | ( | const U8 * | src, | |
S32 | len | |||
) |
Construct a heap buffer of minimum size len, and copy from src.
src | The source of the data to be copied. | |
len | The minimum size of the buffer. |
S32 LLHeapBuffer::bytesLeft | ( | ) | const |
Get the number of bytes left in the buffer.
Note that this is not a virtual function, and only available in the LLHeapBuffer as a debugging aid.
bool LLHeapBuffer::containsSegment | ( | const LLSegment & | segment | ) | const [virtual] |
Test if a segment is inside this buffer.
segment | The contiguous buffer segment to test. |
Implements LLBuffer.
bool LLHeapBuffer::createSegment | ( | S32 | channel, | |
S32 | size, | |||
LLSegment & | segment | |||
) | [virtual] |
Generate a segment for this buffer.
The segment returned is always contiguous memory. This call can fail if no contiguous memory is available, eg, offset is past the end. The segment returned may be smaller than the requested size. It is up to the caller to delete the segment returned.
channel | The channel for the segment. | |
offset | The offset from zero in the buffer | |
size | The requested size of the segment | |
segment[out] | The out-value from the operation |
Implements LLBuffer.
bool LLHeapBuffer::reclaimSegment | ( | const LLSegment & | segment | ) | [virtual] |
reclaim a segment from this buffer.
This method is called on a buffer object when a caller is done with a contiguous segment of memory inside this buffer. Since segments can be cut arbitrarily outside of the control of the buffer, this segment may not match any segment returned from createSegment()
. This call will fail if the segment passed in is note completely inside the buffer, eg, if the segment starts before this buffer in memory or ends after it.
segment | The contiguous buffer segment to reclaim. |
Implements LLBuffer.