42 #ifndef QDECLARATIVEJSMEMORYPOOL_P_H 43 #define QDECLARATIVEJSMEMORYPOOL_P_H 56 #include "private/qdeclarativejsglobal_p.h" 58 #include <QtCore/qglobal.h> 59 #include <QtCore/qshareddata.h> 70 enum { maxBlockCount = -1 };
71 enum { defaultBlockSize = 1 << 12 };
74 m_blockIndex = maxBlockCount;
78 m_currentBlockSize = 0;
89 bytes += (8 - bytes) & 7;
90 if (m_currentBlock == 0 || m_currentBlockSize < m_currentIndex + bytes) {
92 m_currentBlockSize = defaultBlockSize << m_blockIndex;
94 m_storage =
reinterpret_cast<char**
>(
qRealloc(m_storage,
sizeof(
char*) * (1 + m_blockIndex)));
95 m_currentBlock = m_storage[m_blockIndex] =
reinterpret_cast<char*
>(
qMalloc(m_currentBlockSize));
96 ::memset(m_currentBlock, 0, m_currentBlockSize);
98 m_currentIndex = (8 -
quintptr(m_currentBlock)) & 7;
99 Q_ASSERT(m_currentIndex + bytes <= m_currentBlockSize);
102 char *p =
reinterpret_cast<char *
> 103 (m_currentBlock + m_currentIndex);
105 m_currentIndex += bytes;
113 bytes += (defaultBlockSize <<
index);
114 bytes += m_currentIndex;
QIntegerForSizeof< void * >::Unsigned quintptr
char * allocate(int bytes)
Q_CORE_EXPORT void qFree(void *ptr)
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Q_CORE_EXPORT void * qMalloc(size_t size)
Q_CORE_EXPORT void * qRealloc(void *ptr, size_t size)
#define QML_PARSER_EXPORT
#define QT_QML_END_NAMESPACE
#define QT_QML_BEGIN_NAMESPACE
The QSharedData class is a base class for shared data objects.
int bytesAllocated() const