xrootd
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
XrdOucBuffer Class Reference

#include <XrdOucBuffer.hh>

Collaboration diagram for XrdOucBuffer:
Collaboration graph
[legend]

Public Member Functions

char * Buffer () const
 
int BuffSize () const
 
XrdOucBufferClone (bool trim=true)
 
char * Data () const
 
char * Data (int &dataL) const
 
int DataLen ()
 
XrdOucBufferHighjack (int bPsz=0)
 
void Recycle ()
 Recycle the buffer. The buffer may be reused in the future.
 
bool Resize (int newsz)
 
void SetLen (int dataL, int dataO=0)
 
 XrdOucBuffer (char *buff, int blen)
 

Private Member Functions

 XrdOucBuffer (XrdOucBuffPool *pP, int snum)
 
 XrdOucBuffer ()
 
 ~XrdOucBuffer ()
 

Private Attributes

char * data
 
int dlen
 
int doff
 
int size
 
int slot
 
union { 
 
   XrdOucBuffer *   buffNext 
 
   XrdOucBuffPool *   buffPool 
 
};  
 

Friends

class XrdOucBuffPool
 

Constructor & Destructor Documentation

◆ XrdOucBuffer() [1/3]

XrdOucBuffer::XrdOucBuffer ( char *  buff,
int  blen 
)

Public constructor. You can create one-time buffers not associated with a buffer pool via new to associated your own storage area that will be freed when the buffer is recycled. This may be handy to pass along such a buffer to XrdOucErrInfo in a pinch. A one-time buffer is restricted and the Clone(), Highjack() and Resize() methods will always fail. However, all the other methods will work in the expected way.

Parameters
buff- pointer to a storage area obtained via posix_memalign() and it will be released via free().
blen- the size of the buffer as well as the data length. Use SetLen() to set a new data length if it differs.

◆ XrdOucBuffer() [2/3]

XrdOucBuffer::XrdOucBuffer ( XrdOucBuffPool pP,
int  snum 
)
inlineprivate

◆ XrdOucBuffer() [3/3]

XrdOucBuffer::XrdOucBuffer ( )
inlineprivate

◆ ~XrdOucBuffer()

XrdOucBuffer::~XrdOucBuffer ( )
inlineprivate

References data.

Member Function Documentation

◆ Buffer()

char * XrdOucBuffer::Buffer ( ) const
inline

Get the pointer to the buffer.

Returns
pointer to the buffer.

References data.

◆ BuffSize()

int XrdOucBuffer::BuffSize ( ) const
inline

Get the size of the buffer.

Returns
size of the buffer.

References size.

◆ Clone()

XrdOucBuffer * XrdOucBuffer::Clone ( bool  trim = true)

Produce a clone of this buffer.

Parameters
trim- when true the memory buffer is trimmed to be of sufficient size to hold the actual data. Otherwise, the cloned memory buffer is of the same length.
Returns
!0 - pointer to the cloned buffer. =0 - insufficient memory to clone the buffer.

Referenced by XrdOucErrInfo::operator=().

◆ Data() [1/2]

char * XrdOucBuffer::Data ( ) const
inline

Get a pointer to the data in the buffer.

Returns
pointer to the data.

References data, and doff.

Referenced by XrdOucErrInfo::getErrText(), and XrdOucErrInfo::getErrText().

◆ Data() [2/2]

char * XrdOucBuffer::Data ( int &  dataL) const
inline

Get a pointer to the data in the buffer and the length of the data.

Parameters
dataL- place where the length is to be stored.
Returns
pointer to the data with dataL holding its length.

References data, dlen, and doff.

◆ DataLen()

int XrdOucBuffer::DataLen ( )
inline

Get the data length.

Returns
The data length.

References dlen.

Referenced by XrdOucErrInfo::getErrTextLen().

◆ Highjack()

XrdOucBuffer * XrdOucBuffer::Highjack ( int  bPsz = 0)

Highjack the buffer contents and reinitialize the original buffer.

Parameters
bPsz- the desired size to be given to the highjacked buffer. If zero, the current size is used. Same size resictions apply as for buffer pool Alloc(), above.
Returns
!0 - pointer to a usable buffer object which is identical to the original buffer. The original buffer was reallocated with the specified size.
=0 - insufficient memory to allocate a buffer.

◆ Recycle()

void XrdOucBuffer::Recycle ( )
inline

◆ Resize()

bool XrdOucBuffer::Resize ( int  newsz)

Resize the buffer.

Parameters
newsz- the size that the buffer is to have. The same restrictions apply as for buffer pool Alloc(), above.
Returns
true - buffer has been reallocated.
false - insufficient memoy to reallocated the buffer.

◆ SetLen()

void XrdOucBuffer::SetLen ( int  dataL,
int  dataO = 0 
)
inline

Set the data length of offset.

Parameters
dataL- the length of the data.
dataO- the offset of the data in the buffer.

References dlen, and doff.

Friends And Related Symbol Documentation

◆ XrdOucBuffPool

friend class XrdOucBuffPool
friend

Member Data Documentation

◆ [union]

union { ... } XrdOucBuffer

◆ buffNext

XrdOucBuffer* XrdOucBuffer::buffNext

◆ buffPool

XrdOucBuffPool* XrdOucBuffer::buffPool

Referenced by Recycle().

◆ data

char* XrdOucBuffer::data
private

Referenced by Buffer(), Data(), Data(), and ~XrdOucBuffer().

◆ dlen

int XrdOucBuffer::dlen
private

Referenced by Data(), DataLen(), and SetLen().

◆ doff

int XrdOucBuffer::doff
private

Referenced by Data(), Data(), and SetLen().

◆ size

int XrdOucBuffer::size
private

Referenced by BuffSize().

◆ slot

int XrdOucBuffer::slot
private

Referenced by Recycle().


The documentation for this class was generated from the following file: