2#include <soui_mem_wrapper.h>
11 , m_bExternalBuf(false)
29 soui_mem_wrapper::SouiFree(m_pBuf);
43 SASSERT(nBytes <= SIZE_MAX-1);
44 m_pBuf =
static_cast<char*
>(soui_mem_wrapper::SouiMalloc(nBytes+1));
48 memset(m_pBuf, 0, nBytes + 1);
49 m_bExternalBuf =
false;
73 SASSERT(m_pBuf != NULL);
79 SASSERT(m_pBuf != NULL);
85 SASSERT(m_pBuf != NULL);
89 SAutoBuf::operator
char *()
const
Header file for the SAutoBuf class, a smart buffer management class.
const char & operator[](int i) const
Const array subscript operator.
void Free()
Frees the managed buffer. The buffer will be set to nullptr after being freed.
char * operator->() const
Arrow operator to access members of the managed buffer.
void Attach(char *pBuf, size_t size)
Attaches an external buffer to the SAutoBuf object. The buffer will not be freed by the SAutoBuf obje...
char * Allocate(size_t nElements)
Allocates a buffer of the specified size. If a buffer is already allocated, it will be freed first.
~SAutoBuf()
Destructor. Frees the allocated buffer if it was not externally attached.
size_t size()
Returns the size of the managed buffer.
SAutoBuf()
Default constructor. Initializes an empty buffer.
char * Detach()
Detaches the managed buffer from the SAutoBuf object. The caller is responsible for freeing the buffe...