4#ifndef QQMLJSMEMORYPOOL_P_H
5#define QQMLJSMEMORYPOOL_P_H
18#include <QtCore/private/qglobal_p.h>
19#include <QtCore/qstring.h>
20#include <QtCore/qvector.h>
39 for (
int i = 0;
i < _allocatedBlocks; ++
i) {
40 if (
char *
b = _blocks[
i])
56 return allocate_helper(
size);
62 _ptr = _end =
nullptr;
65 template <
typename Tp> Tp *
New() {
return new (this->
allocate(
sizeof(Tp))) Tp(); }
66 template <
typename Tp,
typename... Ta> Tp *
New(Ta...
args)
70 return strings.emplace_back(std::move(
string));
76 size_t currentBlockSize = DEFAULT_BLOCK_SIZE;
78 currentBlockSize *= 2;
80 if (++_blockCount == _allocatedBlocks) {
81 if (! _allocatedBlocks)
82 _allocatedBlocks = DEFAULT_BLOCK_COUNT;
84 _allocatedBlocks *= 2;
86 _blocks =
reinterpret_cast<char **
>(realloc(_blocks,
sizeof(
char *) *
size_t(_allocatedBlocks)));
90 _blocks[
index] =
nullptr;
93 char *&block = _blocks[_blockCount];
96 block =
reinterpret_cast<char *
>(malloc(currentBlockSize));
101 _end = _ptr + currentBlockSize;
109 char **_blocks =
nullptr;
110 int _allocatedBlocks = 0;
111 int _blockCount = -1;
112 char *_ptr =
nullptr;
113 char *_end =
nullptr;
118 DEFAULT_BLOCK_SIZE = 8 * 1024,
119 DEFAULT_BLOCK_COUNT = 8
131 void operator delete(
void *) {}
QStringView newString(QString string)
void * allocate(size_t size)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei const GLchar ** strings
[1]
Q_CHECK_PTR(a=new int[80])