Qt 4.8
Public Types | Public Functions | Properties | List of all members
QTestCharBuffer Struct Reference

#include <qabstracttestlogger_p.h>

Public Types

enum  { InitialSize = 512 }
 

Public Functions

char ** buffer ()
 
const char * constData () const
 
char * data ()
 
 QTestCharBuffer ()
 
bool reset (int newSize)
 
int size () const
 
 ~QTestCharBuffer ()
 

Properties

int _size
 
char * buf
 
char staticBuf [InitialSize]
 

Detailed Description

Definition at line 104 of file qabstracttestlogger_p.h.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
InitialSize 

Definition at line 106 of file qabstracttestlogger_p.h.

Constructors and Destructors

◆ QTestCharBuffer()

QTestCharBuffer::QTestCharBuffer ( )
inline

◆ ~QTestCharBuffer()

QTestCharBuffer::~QTestCharBuffer ( )
inline

Definition at line 114 of file qabstracttestlogger_p.h.

115  {
116  if (buf != staticBuf)
117  qFree(buf);
118  }
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
char staticBuf[InitialSize]

Functions

◆ buffer()

char** QTestCharBuffer::buffer ( )
inline

Definition at line 125 of file qabstracttestlogger_p.h.

126  {
127  return &buf;
128  }

◆ constData()

const char* QTestCharBuffer::constData ( ) const
inline

◆ data()

char* QTestCharBuffer::data ( )
inline

◆ reset()

bool QTestCharBuffer::reset ( int  newSize)
inline

Definition at line 140 of file qabstracttestlogger_p.h.

Referenced by allocateStringFn(), and QTest::qt_asprintf().

141  {
142  char *newBuf = 0;
143  if (buf == staticBuf) {
144  // if we point to our internal buffer, we need to malloc first
145  newBuf = reinterpret_cast<char *>(qMalloc(newSize));
146  } else {
147  // if we already malloc'ed, just realloc
148  newBuf = reinterpret_cast<char *>(qRealloc(buf, newSize));
149  }
150 
151  // if the allocation went wrong (newBuf == 0), we leave the object as is
152  if (!newBuf)
153  return false;
154 
155  _size = newSize;
156  buf = newBuf;
157  return true;
158  }
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
Q_CORE_EXPORT void * qRealloc(void *ptr, size_t size)
Definition: qmalloc.cpp:63
char staticBuf[InitialSize]

◆ size()

int QTestCharBuffer::size ( ) const
inline

Definition at line 135 of file qabstracttestlogger_p.h.

Referenced by allocateStringFn(), and QTest::qt_asprintf().

136  {
137  return _size;
138  }

Properties

◆ _size

int QTestCharBuffer::_size
private

Definition at line 161 of file qabstracttestlogger_p.h.

◆ buf

char* QTestCharBuffer::buf
private

Definition at line 162 of file qabstracttestlogger_p.h.

◆ staticBuf

char QTestCharBuffer::staticBuf[InitialSize]
private

Definition at line 163 of file qabstracttestlogger_p.h.


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