diff options
Diffstat (limited to 'src/tools/qdoc/qmlparser/qqmljsmemorypool_p.h')
-rw-r--r-- | src/tools/qdoc/qmlparser/qqmljsmemorypool_p.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/tools/qdoc/qmlparser/qqmljsmemorypool_p.h b/src/tools/qdoc/qmlparser/qqmljsmemorypool_p.h index f8bb70c54c..16927251c7 100644 --- a/src/tools/qdoc/qmlparser/qqmljsmemorypool_p.h +++ b/src/tools/qdoc/qmlparser/qqmljsmemorypool_p.h @@ -57,6 +57,8 @@ QT_QML_BEGIN_NAMESPACE namespace QQmlJS { +class Managed; + class QML_PARSER_EXPORT MemoryPool : public QSharedData { MemoryPool(const MemoryPool &other); @@ -100,6 +102,30 @@ public: _ptr = _end = 0; } + template <typename _Tp> _Tp *New() { return new (this->allocate(sizeof(_Tp))) _Tp(); } + + template <typename PoolContentType, typename Visitor> + void visitManagedPool(Visitor &visitor) + { + for (int i = 0; i <= _blockCount; ++i) { + char *p = _blocks[i]; + char *end = p + BLOCK_SIZE; + if (i == _blockCount) { + Q_ASSERT(_ptr <= end); + end = _ptr; + } + + Q_ASSERT(p <= end); + + const qptrdiff increment = (sizeof(PoolContentType) + 7) & ~7; + + while (p + increment <= end) { + visitor(reinterpret_cast<PoolContentType*>(p)); + p += increment; + } + } + } + private: void *allocate_helper(size_t size) { |