XrdOucBuffer Class Reference

#include <XrdOucBuffer.hh>

Collaboration diagram for XrdOucBuffer:
Collaboration graph
[legend]

List of all members.

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::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 malloc and its relatives (e.g. memalign). 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::XrdOucBuffer ( XrdOucBuffPool pP,
int  snum 
) [inline, private]
XrdOucBuffer::XrdOucBuffer (  )  [inline, private]
XrdOucBuffer::~XrdOucBuffer (  )  [inline, private]

References data.


Member Function Documentation

char* XrdOucBuffer::Buffer (  )  const [inline]

Get the pointer to the buffer.

Returns:
pointer to the buffer.

References data.

int XrdOucBuffer::BuffSize ( void   )  const [inline]

Get the size of the buffer.

Returns:
size of the buffer.

References size.

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=().

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.

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().

int XrdOucBuffer::DataLen (  )  [inline]

Get the data length.

Returns:
The data length.

References dlen.

Referenced by XrdOucErrInfo::getErrTextLen().

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

Highjack the buffer contents and reinitialize the original buffer.

Parameters:
xsz - 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.
void XrdOucBuffer::Recycle ( void   )  [inline]

Recycle the buffer. The buffer may be reused in the future.

References XrdOucBuffPool::bSlot, buffPool, and slot.

Referenced by XrdOucErrInfo::Reset(), and XrdOucErrInfo::setErrInfo().

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.
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 Function Documentation

friend class XrdOucBuffPool [friend]

Member Data Documentation

union { ... } [private]

Referenced by Recycle().

char* XrdOucBuffer::data [private]

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

int XrdOucBuffer::dlen [private]

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

int XrdOucBuffer::doff [private]

Referenced by Data(), and SetLen().

int XrdOucBuffer::size [private]

Referenced by BuffSize().

int XrdOucBuffer::slot [private]

Referenced by Recycle().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 19 Oct 2019 for xrootd by  doxygen 1.6.1