mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
cleanup containers methods and use of deprecated allocation methods
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
446bedd388
commit
f9540805d1
47 changed files with 228 additions and 331 deletions
|
@ -804,7 +804,7 @@ QTextCodec::ConverterState::~ConverterState()
|
|||
if (flags & FreeFunction)
|
||||
(QTextCodecUnalignedPointer::decode(state_data))(this);
|
||||
else if (d)
|
||||
qFree(d);
|
||||
free(d);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -3103,7 +3103,7 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
|
|||
void *actualptr = oldptr ? static_cast<void **>(oldptr)[-1] : 0;
|
||||
if (alignment <= sizeof(void*)) {
|
||||
// special, fast case
|
||||
void **newptr = static_cast<void **>(qRealloc(actualptr, newsize + sizeof(void*)));
|
||||
void **newptr = static_cast<void **>(realloc(actualptr, newsize + sizeof(void*)));
|
||||
if (!newptr)
|
||||
return 0;
|
||||
if (newptr == actualptr) {
|
||||
|
@ -3123,7 +3123,7 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
|
|||
// However, we need to store the actual pointer, so we need to allocate actually size +
|
||||
// alignment anyway.
|
||||
|
||||
void *real = qRealloc(actualptr, newsize + alignment);
|
||||
void *real = realloc(actualptr, newsize + alignment);
|
||||
if (!real)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ public:
|
|||
|
||||
SidCleanup::~SidCleanup()
|
||||
{
|
||||
qFree(currentUserSID);
|
||||
free(currentUserSID);
|
||||
currentUserSID = 0;
|
||||
|
||||
// worldSID was allocated with AllocateAndInitializeSid so it needs to be freed with FreeSid
|
||||
|
@ -231,15 +231,15 @@ static void resolveLibs()
|
|||
// doing a dummy GetTokenInformation call.
|
||||
::GetTokenInformation(token, TokenUser, 0, 0, &retsize);
|
||||
if (retsize) {
|
||||
void *tokenBuffer = qMalloc(retsize);
|
||||
void *tokenBuffer = malloc(retsize);
|
||||
if (::GetTokenInformation(token, TokenUser, tokenBuffer, retsize, &retsize)) {
|
||||
PSID tokenSid = reinterpret_cast<PTOKEN_USER>(tokenBuffer)->User.Sid;
|
||||
DWORD sidLen = ::GetLengthSid(tokenSid);
|
||||
currentUserSID = reinterpret_cast<PSID>(qMalloc(sidLen));
|
||||
currentUserSID = reinterpret_cast<PSID>(malloc(sidLen));
|
||||
if (::CopySid(sidLen, currentUserSID, tokenSid))
|
||||
ptrBuildTrusteeWithSidW(¤tUserTrusteeW, currentUserSID);
|
||||
}
|
||||
qFree(tokenBuffer);
|
||||
free(tokenBuffer);
|
||||
}
|
||||
::CloseHandle(token);
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ static QString readSymLink(const QFileSystemEntry &link)
|
|||
0);
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
DWORD bufsize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
|
||||
REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)qMalloc(bufsize);
|
||||
REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)malloc(bufsize);
|
||||
DWORD retsize = 0;
|
||||
if (::DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, 0, 0, rdb, bufsize, &retsize, 0)) {
|
||||
if (rdb->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
|
||||
|
@ -332,7 +332,7 @@ static QString readSymLink(const QFileSystemEntry &link)
|
|||
if (result.size() > 4 && result.at(0) == QLatin1Char('\\') && result.at(2) == QLatin1Char('?') && result.at(3) == QLatin1Char('\\'))
|
||||
result = result.mid(4);
|
||||
}
|
||||
qFree(rdb);
|
||||
free(rdb);
|
||||
CloseHandle(handle);
|
||||
|
||||
#if !defined(QT_NO_LIBRARY)
|
||||
|
|
|
@ -1615,9 +1615,9 @@ bool QMetaMethod::invoke(QObject *object,
|
|||
}
|
||||
|
||||
int nargs = 1; // include return type
|
||||
void **args = (void **) qMalloc(paramCount * sizeof(void *));
|
||||
void **args = (void **) malloc(paramCount * sizeof(void *));
|
||||
Q_CHECK_PTR(args);
|
||||
int *types = (int *) qMalloc(paramCount * sizeof(int));
|
||||
int *types = (int *) malloc(paramCount * sizeof(int));
|
||||
Q_CHECK_PTR(types);
|
||||
types[0] = 0; // return type
|
||||
args[0] = 0;
|
||||
|
@ -1634,8 +1634,8 @@ bool QMetaMethod::invoke(QObject *object,
|
|||
if (types[x] && args[x])
|
||||
QMetaType::destroy(types[x], args[x]);
|
||||
}
|
||||
qFree(types);
|
||||
qFree(args);
|
||||
free(types);
|
||||
free(args);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -464,8 +464,8 @@ QMetaCallEvent::~QMetaCallEvent()
|
|||
if (types_[i] && args_[i])
|
||||
QMetaType::destroy(types_[i], args_[i]);
|
||||
}
|
||||
qFree(types_);
|
||||
qFree(args_);
|
||||
free(types_);
|
||||
free(args_);
|
||||
}
|
||||
#ifndef QT_NO_THREAD
|
||||
if (semaphore_)
|
||||
|
@ -3127,9 +3127,9 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
|
|||
int nargs = 1; // include return type
|
||||
while (c->argumentTypes[nargs-1])
|
||||
++nargs;
|
||||
int *types = (int *) qMalloc(nargs*sizeof(int));
|
||||
int *types = (int *) malloc(nargs*sizeof(int));
|
||||
Q_CHECK_PTR(types);
|
||||
void **args = (void **) qMalloc(nargs*sizeof(void *));
|
||||
void **args = (void **) malloc(nargs*sizeof(void *));
|
||||
Q_CHECK_PTR(args);
|
||||
types[0] = 0; // return type
|
||||
args[0] = 0; // return value
|
||||
|
|
|
@ -549,7 +549,7 @@ QByteArray qUncompress(const uchar* data, int nbytes)
|
|||
qWarning("qUncompress: Input data is corrupted");
|
||||
return QByteArray();
|
||||
}
|
||||
QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + alloc));
|
||||
QByteArray::Data *p = static_cast<QByteArray::Data *>(realloc(d.data(), sizeof(QByteArray::Data) + alloc));
|
||||
if (!p) {
|
||||
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
|
||||
qWarning("qUncompress: could not allocate enough memory to uncompress data");
|
||||
|
@ -569,7 +569,7 @@ QByteArray qUncompress(const uchar* data, int nbytes)
|
|||
qWarning("qUncompress: Input data is corrupted");
|
||||
return QByteArray();
|
||||
}
|
||||
QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + len));
|
||||
QByteArray::Data *p = static_cast<QByteArray::Data *>(realloc(d.data(), sizeof(QByteArray::Data) + len));
|
||||
if (!p) {
|
||||
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
|
||||
qWarning("qUncompress: could not allocate enough memory to uncompress data");
|
||||
|
@ -904,7 +904,7 @@ QByteArray &QByteArray::operator=(const QByteArray & other)
|
|||
{
|
||||
other.d->ref.ref();
|
||||
if (!d->ref.deref())
|
||||
qFree(d);
|
||||
free(d);
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
@ -926,14 +926,14 @@ QByteArray &QByteArray::operator=(const char *str)
|
|||
} else {
|
||||
int len = qstrlen(str);
|
||||
if (d->ref != 1 || len > d->alloc || (len < d->size && len < d->alloc >> 1))
|
||||
realloc(len);
|
||||
reallocData(len);
|
||||
x = d;
|
||||
memcpy(x->data, str, len + 1); // include null terminator
|
||||
x->size = len;
|
||||
}
|
||||
x->ref.ref();
|
||||
if (!d->ref.deref())
|
||||
qFree(d);
|
||||
free(d);
|
||||
d = x;
|
||||
return *this;
|
||||
}
|
||||
|
@ -1323,7 +1323,7 @@ QByteArray::QByteArray(const char *str)
|
|||
d = &shared_empty;
|
||||
} else {
|
||||
int len = qstrlen(str);
|
||||
d = static_cast<Data *>(qMalloc(sizeof(Data)+len));
|
||||
d = static_cast<Data *>(malloc(sizeof(Data)+len));
|
||||
Q_CHECK_PTR(d);
|
||||
d->ref = 0;;
|
||||
d->alloc = d->size = len;
|
||||
|
@ -1351,7 +1351,7 @@ QByteArray::QByteArray(const char *data, int size)
|
|||
} else if (size <= 0) {
|
||||
d = &shared_empty;
|
||||
} else {
|
||||
d = static_cast<Data *>(qMalloc(sizeof(Data) + size));
|
||||
d = static_cast<Data *>(malloc(sizeof(Data) + size));
|
||||
Q_CHECK_PTR(d);
|
||||
d->ref = 0;
|
||||
d->alloc = d->size = size;
|
||||
|
@ -1374,7 +1374,7 @@ QByteArray::QByteArray(int size, char ch)
|
|||
if (size <= 0) {
|
||||
d = &shared_null;
|
||||
} else {
|
||||
d = static_cast<Data *>(qMalloc(sizeof(Data)+size));
|
||||
d = static_cast<Data *>(malloc(sizeof(Data)+size));
|
||||
Q_CHECK_PTR(d);
|
||||
d->ref = 0;
|
||||
d->alloc = d->size = size;
|
||||
|
@ -1396,7 +1396,7 @@ QByteArray::QByteArray(int size, Qt::Initialization)
|
|||
if (size <= 0) {
|
||||
d = &shared_empty;
|
||||
} else {
|
||||
d = static_cast<Data *>(qMalloc(sizeof(Data)+size));
|
||||
d = static_cast<Data *>(malloc(sizeof(Data)+size));
|
||||
Q_CHECK_PTR(d);
|
||||
d->ref = 0;
|
||||
d->alloc = d->size = size;
|
||||
|
@ -1425,7 +1425,7 @@ void QByteArray::resize(int size)
|
|||
Data *x = &shared_empty;
|
||||
x->ref.ref();
|
||||
if (!d->ref.deref())
|
||||
qFree(d);
|
||||
free(d);
|
||||
d = x;
|
||||
} else if (d == &shared_null) {
|
||||
//
|
||||
|
@ -1436,7 +1436,7 @@ void QByteArray::resize(int size)
|
|||
// which is used in place of the Qt 3 idiom:
|
||||
// QByteArray a(sz);
|
||||
//
|
||||
Data *x = static_cast<Data *>(qMalloc(sizeof(Data)+size));
|
||||
Data *x = static_cast<Data *>(malloc(sizeof(Data)+size));
|
||||
Q_CHECK_PTR(x);
|
||||
x->ref = 1;
|
||||
x->alloc = x->size = size;
|
||||
|
@ -1446,7 +1446,7 @@ void QByteArray::resize(int size)
|
|||
d = x;
|
||||
} else {
|
||||
if (d->ref != 1 || size > d->alloc || (size < d->size && size < d->alloc >> 1))
|
||||
realloc(qAllocMore(size, sizeof(Data)));
|
||||
reallocData(qAllocMore(size, sizeof(Data)));
|
||||
if (d->alloc >= size) {
|
||||
d->size = size;
|
||||
if (d->data == d->array) {
|
||||
|
@ -1475,10 +1475,10 @@ QByteArray &QByteArray::fill(char ch, int size)
|
|||
return *this;
|
||||
}
|
||||
|
||||
void QByteArray::realloc(int alloc)
|
||||
void QByteArray::reallocData(int alloc)
|
||||
{
|
||||
if (d->ref != 1 || d->data != d->array) {
|
||||
Data *x = static_cast<Data *>(qMalloc(sizeof(Data) + alloc));
|
||||
Data *x = static_cast<Data *>(malloc(sizeof(Data) + alloc));
|
||||
Q_CHECK_PTR(x);
|
||||
x->size = qMin(alloc, d->size);
|
||||
::memcpy(x->array, d->data, x->size);
|
||||
|
@ -1487,10 +1487,10 @@ void QByteArray::realloc(int alloc)
|
|||
x->alloc = alloc;
|
||||
x->data = x->array;
|
||||
if (!d->ref.deref())
|
||||
qFree(d);
|
||||
free(d);
|
||||
d = x;
|
||||
} else {
|
||||
Data *x = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc));
|
||||
Data *x = static_cast<Data *>(realloc(d, sizeof(Data) + alloc));
|
||||
Q_CHECK_PTR(x);
|
||||
x->alloc = alloc;
|
||||
x->data = x->array;
|
||||
|
@ -1578,7 +1578,7 @@ QByteArray &QByteArray::prepend(const char *str, int len)
|
|||
{
|
||||
if (str) {
|
||||
if (d->ref != 1 || d->size + len > d->alloc)
|
||||
realloc(qAllocMore(d->size + len, sizeof(Data)));
|
||||
reallocData(qAllocMore(d->size + len, sizeof(Data)));
|
||||
memmove(d->data+len, d->data, d->size);
|
||||
memcpy(d->data, str, len);
|
||||
d->size += len;
|
||||
|
@ -1596,7 +1596,7 @@ QByteArray &QByteArray::prepend(const char *str, int len)
|
|||
QByteArray &QByteArray::prepend(char ch)
|
||||
{
|
||||
if (d->ref != 1 || d->size + 1 > d->alloc)
|
||||
realloc(qAllocMore(d->size + 1, sizeof(Data)));
|
||||
reallocData(qAllocMore(d->size + 1, sizeof(Data)));
|
||||
memmove(d->data+1, d->data, d->size);
|
||||
d->data[0] = ch;
|
||||
++d->size;
|
||||
|
@ -1634,7 +1634,7 @@ QByteArray &QByteArray::append(const QByteArray &ba)
|
|||
*this = ba;
|
||||
} else if (ba.d != &shared_null) {
|
||||
if (d->ref != 1 || d->size + ba.d->size > d->alloc)
|
||||
realloc(qAllocMore(d->size + ba.d->size, sizeof(Data)));
|
||||
reallocData(qAllocMore(d->size + ba.d->size, sizeof(Data)));
|
||||
memcpy(d->data + d->size, ba.d->data, ba.d->size);
|
||||
d->size += ba.d->size;
|
||||
d->data[d->size] = '\0';
|
||||
|
@ -1668,7 +1668,7 @@ QByteArray& QByteArray::append(const char *str)
|
|||
if (str) {
|
||||
int len = qstrlen(str);
|
||||
if (d->ref != 1 || d->size + len > d->alloc)
|
||||
realloc(qAllocMore(d->size + len, sizeof(Data)));
|
||||
reallocData(qAllocMore(d->size + len, sizeof(Data)));
|
||||
memcpy(d->data + d->size, str, len + 1); // include null terminator
|
||||
d->size += len;
|
||||
}
|
||||
|
@ -1693,7 +1693,7 @@ QByteArray &QByteArray::append(const char *str, int len)
|
|||
len = qstrlen(str);
|
||||
if (str && len) {
|
||||
if (d->ref != 1 || d->size + len > d->alloc)
|
||||
realloc(qAllocMore(d->size + len, sizeof(Data)));
|
||||
reallocData(qAllocMore(d->size + len, sizeof(Data)));
|
||||
memcpy(d->data + d->size, str, len); // include null terminator
|
||||
d->size += len;
|
||||
d->data[d->size] = '\0';
|
||||
|
@ -1710,7 +1710,7 @@ QByteArray &QByteArray::append(const char *str, int len)
|
|||
QByteArray& QByteArray::append(char ch)
|
||||
{
|
||||
if (d->ref != 1 || d->size + 1 > d->alloc)
|
||||
realloc(qAllocMore(d->size + 1, sizeof(Data)));
|
||||
reallocData(qAllocMore(d->size + 1, sizeof(Data)));
|
||||
d->data[d->size++] = ch;
|
||||
d->data[d->size] = '\0';
|
||||
return *this;
|
||||
|
@ -2743,7 +2743,7 @@ QByteArray QByteArray::toUpper() const
|
|||
void QByteArray::clear()
|
||||
{
|
||||
if (!d->ref.deref())
|
||||
qFree(d);
|
||||
free(d);
|
||||
d = &shared_null;
|
||||
d->ref.ref();
|
||||
}
|
||||
|
@ -3893,7 +3893,7 @@ QByteArray QByteArray::number(double n, char f, int prec)
|
|||
|
||||
QByteArray QByteArray::fromRawData(const char *data, int size)
|
||||
{
|
||||
Data *x = static_cast<Data *>(qMalloc(sizeof(Data)));
|
||||
Data *x = static_cast<Data *>(malloc(sizeof(Data)));
|
||||
Q_CHECK_PTR(x);
|
||||
if (data) {
|
||||
x->data = const_cast<char *>(data);
|
||||
|
|
|
@ -353,7 +353,7 @@ private:
|
|||
static Data shared_empty;
|
||||
Data *d;
|
||||
QByteArray(Data *dd, int /*dummy*/, int /*dummy*/) : d(dd) {}
|
||||
void realloc(int alloc);
|
||||
void reallocData(int alloc);
|
||||
void expand(int i);
|
||||
QByteArray nulTerminated() const;
|
||||
|
||||
|
@ -366,7 +366,7 @@ public:
|
|||
};
|
||||
|
||||
inline QByteArray::QByteArray(): d(&shared_null) { d->ref.ref(); }
|
||||
inline QByteArray::~QByteArray() { if (!d->ref.deref()) qFree(d); }
|
||||
inline QByteArray::~QByteArray() { if (!d->ref.deref()) free(d); }
|
||||
inline int QByteArray::size() const
|
||||
{ return d->size; }
|
||||
|
||||
|
@ -401,7 +401,7 @@ inline const char *QByteArray::data() const
|
|||
inline const char *QByteArray::constData() const
|
||||
{ return d->data; }
|
||||
inline void QByteArray::detach()
|
||||
{ if (d->ref != 1 || d->data != d->array) realloc(d->size); }
|
||||
{ if (d->ref != 1 || d->data != d->array) reallocData(d->size); }
|
||||
inline bool QByteArray::isDetached() const
|
||||
{ return d->ref == 1; }
|
||||
inline QByteArray::QByteArray(const QByteArray &a) : d(a.d)
|
||||
|
@ -411,10 +411,10 @@ inline int QByteArray::capacity() const
|
|||
{ return d->alloc; }
|
||||
|
||||
inline void QByteArray::reserve(int asize)
|
||||
{ if (d->ref != 1 || asize > d->alloc) realloc(asize); }
|
||||
{ if (d->ref != 1 || asize > d->alloc) reallocData(asize); }
|
||||
|
||||
inline void QByteArray::squeeze()
|
||||
{ if (d->size < d->alloc) realloc(d->size); }
|
||||
{ if (d->size < d->alloc) reallocData(d->size); }
|
||||
|
||||
class Q_CORE_EXPORT QByteRef {
|
||||
QByteArray &a;
|
||||
|
|
|
@ -61,7 +61,7 @@ QContiguousCacheData *QContiguousCacheData::allocate(int size, int alignment)
|
|||
return static_cast<QContiguousCacheData *>(qMallocAligned(size, alignment));
|
||||
}
|
||||
|
||||
void QContiguousCacheData::free(QContiguousCacheData *data)
|
||||
void QContiguousCacheData::freeData(QContiguousCacheData *data)
|
||||
{
|
||||
qFreeAligned(data);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ struct Q_CORE_EXPORT QContiguousCacheData
|
|||
// (such as long double on 64-bit platforms, __int128, __float128)
|
||||
|
||||
static QContiguousCacheData *allocate(int size, int alignment);
|
||||
static void free(QContiguousCacheData *data);
|
||||
static void freeData(QContiguousCacheData *data);
|
||||
|
||||
#ifdef QT_QCONTIGUOUSCACHE_DEBUG
|
||||
void dump() const;
|
||||
|
@ -82,7 +82,7 @@ struct QContiguousCacheTypedData: private QContiguousCacheData
|
|||
// private inheritance to avoid aliasing warningss
|
||||
T array[1];
|
||||
|
||||
static inline void free(QContiguousCacheTypedData *data) { QContiguousCacheData::free(data); }
|
||||
static inline void free(QContiguousCacheTypedData *data) { QContiguousCacheData::freeData(data); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -171,7 +171,7 @@ QHashData QHashData::shared_null = {
|
|||
|
||||
void *QHashData::allocateNode(int nodeAlign)
|
||||
{
|
||||
void *ptr = strictAlignment ? qMallocAligned(nodeSize, nodeAlign) : qMalloc(nodeSize);
|
||||
void *ptr = strictAlignment ? qMallocAligned(nodeSize, nodeAlign) : malloc(nodeSize);
|
||||
Q_CHECK_PTR(ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ void QHashData::freeNode(void *node)
|
|||
if (strictAlignment)
|
||||
qFreeAligned(node);
|
||||
else
|
||||
qFree(node);
|
||||
free(node);
|
||||
}
|
||||
|
||||
QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),
|
||||
|
|
|
@ -82,7 +82,7 @@ QListData::Data *QListData::detach_grow(int *idx, int num)
|
|||
int l = x->end - x->begin;
|
||||
int nl = l + num;
|
||||
int alloc = grow(nl);
|
||||
Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + alloc * sizeof(void *)));
|
||||
Data* t = static_cast<Data *>(malloc(DataHeaderSize + alloc * sizeof(void *)));
|
||||
Q_CHECK_PTR(t);
|
||||
|
||||
t->ref = 1;
|
||||
|
@ -113,64 +113,6 @@ QListData::Data *QListData::detach_grow(int *idx, int num)
|
|||
return x;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
# error "Remove QListData::detach(), it is only required for binary compatibility for 4.0.x to 4.2.x"
|
||||
#endif
|
||||
QListData::Data *QListData::detach()
|
||||
{
|
||||
Data *x = static_cast<Data *>(qMalloc(DataHeaderSize + d->alloc * sizeof(void *)));
|
||||
Q_CHECK_PTR(x);
|
||||
|
||||
x->ref = 1;
|
||||
x->sharable = true;
|
||||
x->alloc = d->alloc;
|
||||
if (!x->alloc) {
|
||||
x->begin = 0;
|
||||
x->end = 0;
|
||||
} else {
|
||||
x->begin = d->begin;
|
||||
x->end = d->end;
|
||||
}
|
||||
|
||||
qSwap(d, x);
|
||||
if (!x->ref.deref())
|
||||
return x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Detaches the QListData by reallocating new memory.
|
||||
* Returns the old (shared) data, it is up to the caller to deref() and free()
|
||||
* For the new data node_copy needs to be called.
|
||||
*
|
||||
* \internal
|
||||
*/
|
||||
#if QT_VERSION >= 0x050000
|
||||
# error "Remove QListData::detach2(), it is only required for binary compatibility for 4.3.x to 4.5.x"
|
||||
#endif
|
||||
QListData::Data *QListData::detach2()
|
||||
{
|
||||
Data *x = d;
|
||||
Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + x->alloc * sizeof(void *)));
|
||||
Q_CHECK_PTR(t);
|
||||
|
||||
::memcpy(t, d, DataHeaderSize + d->alloc * sizeof(void *));
|
||||
|
||||
t->ref = 1;
|
||||
t->sharable = true;
|
||||
t->alloc = x->alloc;
|
||||
if (!t->alloc) {
|
||||
t->begin = 0;
|
||||
t->end = 0;
|
||||
} else {
|
||||
t->begin = x->begin;
|
||||
t->end = x->end;
|
||||
}
|
||||
d = t;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Detaches the QListData by allocating new memory for a list which possibly
|
||||
* has a different size than the copied one.
|
||||
|
@ -182,7 +124,7 @@ QListData::Data *QListData::detach2()
|
|||
QListData::Data *QListData::detach(int alloc)
|
||||
{
|
||||
Data *x = d;
|
||||
Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + alloc * sizeof(void *)));
|
||||
Data* t = static_cast<Data *>(malloc(DataHeaderSize + alloc * sizeof(void *)));
|
||||
Q_CHECK_PTR(t);
|
||||
|
||||
t->ref = 1;
|
||||
|
@ -207,18 +149,10 @@ QListData::Data *QListData::detach(int alloc)
|
|||
*
|
||||
* \internal
|
||||
*/
|
||||
#if QT_VERSION >= 0x050000
|
||||
# error "Remove QListData::detach3(), it is only required for binary compatibility for 4.5.x to 4.6.x"
|
||||
#endif
|
||||
QListData::Data *QListData::detach3()
|
||||
{
|
||||
return detach(d->alloc);
|
||||
}
|
||||
|
||||
void QListData::realloc(int alloc)
|
||||
void QListData::reallocData(int alloc)
|
||||
{
|
||||
Q_ASSERT(d->ref == 1);
|
||||
Data *x = static_cast<Data *>(qRealloc(d, DataHeaderSize + alloc * sizeof(void *)));
|
||||
Data *x = static_cast<Data *>(realloc(d, DataHeaderSize + alloc * sizeof(void *)));
|
||||
Q_CHECK_PTR(x);
|
||||
|
||||
d = x;
|
||||
|
@ -240,7 +174,7 @@ void **QListData::append(int n)
|
|||
::memmove(d->array, d->array + b, e * sizeof(void *));
|
||||
d->begin = 0;
|
||||
} else {
|
||||
realloc(grow(d->alloc + n));
|
||||
reallocData(grow(d->alloc + n));
|
||||
}
|
||||
}
|
||||
d->end = e + n;
|
||||
|
@ -254,25 +188,7 @@ void **QListData::append()
|
|||
}
|
||||
|
||||
// ensures that enough space is available to append the list
|
||||
#if QT_VERSION >= 0x050000
|
||||
# error "Remove QListData::append(), it is only required for binary compatibility up to 4.5.x"
|
||||
#endif
|
||||
void **QListData::append(const QListData& l)
|
||||
{
|
||||
Q_ASSERT(d->ref == 1);
|
||||
int e = d->end;
|
||||
int n = l.d->end - l.d->begin;
|
||||
if (n) {
|
||||
if (e + n > d->alloc)
|
||||
realloc(grow(e + n));
|
||||
::memcpy(d->array + d->end, l.d->array + l.d->begin, n*sizeof(void*));
|
||||
d->end += n;
|
||||
}
|
||||
return d->array + e;
|
||||
}
|
||||
|
||||
// ensures that enough space is available to append the list
|
||||
void **QListData::append2(const QListData& l)
|
||||
{
|
||||
return append(l.d->end - l.d->begin);
|
||||
}
|
||||
|
@ -282,7 +198,7 @@ void **QListData::prepend()
|
|||
Q_ASSERT(d->ref == 1);
|
||||
if (d->begin == 0) {
|
||||
if (d->end >= d->alloc / 3)
|
||||
realloc(grow(d->alloc + 1));
|
||||
reallocData(grow(d->alloc + 1));
|
||||
|
||||
if (d->end < d->alloc / 3)
|
||||
d->begin = d->alloc - 2 * d->end;
|
||||
|
@ -309,7 +225,7 @@ void **QListData::insert(int i)
|
|||
if (d->begin == 0) {
|
||||
if (d->end == d->alloc) {
|
||||
// If the array is full, we expand it and move some items rightward
|
||||
realloc(grow(d->alloc + 1));
|
||||
reallocData(grow(d->alloc + 1));
|
||||
} else {
|
||||
// If there is free space at the end of the array, we move some items rightward
|
||||
}
|
||||
|
|
|
@ -78,17 +78,13 @@ struct Q_CORE_EXPORT QListData {
|
|||
|
||||
Data *detach(int alloc);
|
||||
Data *detach_grow(int *i, int n);
|
||||
Data *detach(); // remove in 5.0
|
||||
Data *detach2(); // remove in 5.0
|
||||
Data *detach3(); // remove in 5.0
|
||||
void realloc(int alloc);
|
||||
void reallocData(int alloc);
|
||||
static Data shared_null;
|
||||
Data *d;
|
||||
void **erase(void **xi);
|
||||
void **append(int n);
|
||||
void **append();
|
||||
void **append(const QListData &l);
|
||||
void **append2(const QListData &l); // remove in 5.0
|
||||
void **prepend();
|
||||
void **insert(int i);
|
||||
void remove(int i);
|
||||
|
@ -338,7 +334,7 @@ private:
|
|||
Node *detach_helper_grow(int i, int n);
|
||||
void detach_helper(int alloc);
|
||||
void detach_helper();
|
||||
void free(QListData::Data *d);
|
||||
void freeData(QListData::Data *d);
|
||||
|
||||
void node_construct(Node *n, const T &t);
|
||||
void node_destruct(Node *n);
|
||||
|
@ -485,7 +481,7 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::reserve(int alloc)
|
|||
if (d->ref != 1)
|
||||
detach_helper(alloc);
|
||||
else
|
||||
p.realloc(alloc);
|
||||
p.reallocData(alloc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -667,7 +663,7 @@ Q_OUTOFLINE_TEMPLATE typename QList<T>::Node *QList<T>::detach_helper_grow(int i
|
|||
node_copy(reinterpret_cast<Node *>(p.begin()),
|
||||
reinterpret_cast<Node *>(p.begin() + i), n);
|
||||
} QT_CATCH(...) {
|
||||
qFree(d);
|
||||
free(d);
|
||||
d = x;
|
||||
QT_RETHROW;
|
||||
}
|
||||
|
@ -677,7 +673,7 @@ Q_OUTOFLINE_TEMPLATE typename QList<T>::Node *QList<T>::detach_helper_grow(int i
|
|||
} QT_CATCH(...) {
|
||||
node_destruct(reinterpret_cast<Node *>(p.begin()),
|
||||
reinterpret_cast<Node *>(p.begin() + i));
|
||||
qFree(d);
|
||||
free(d);
|
||||
d = x;
|
||||
QT_RETHROW;
|
||||
}
|
||||
|
@ -696,7 +692,7 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::detach_helper(int alloc)
|
|||
QT_TRY {
|
||||
node_copy(reinterpret_cast<Node *>(p.begin()), reinterpret_cast<Node *>(p.end()), n);
|
||||
} QT_CATCH(...) {
|
||||
qFree(d);
|
||||
free(d);
|
||||
d = x;
|
||||
QT_RETHROW;
|
||||
}
|
||||
|
@ -736,13 +732,12 @@ Q_OUTOFLINE_TEMPLATE bool QList<T>::operator==(const QList<T> &l) const
|
|||
return true;
|
||||
}
|
||||
|
||||
// ### Qt 5: rename freeData() to avoid confusion with std::free()
|
||||
template <typename T>
|
||||
Q_OUTOFLINE_TEMPLATE void QList<T>::free(QListData::Data *data)
|
||||
Q_OUTOFLINE_TEMPLATE void QList<T>::freeData(QListData::Data *data)
|
||||
{
|
||||
node_destruct(reinterpret_cast<Node *>(data->array + data->begin),
|
||||
reinterpret_cast<Node *>(data->array + data->end));
|
||||
qFree(data);
|
||||
free(data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -809,7 +804,7 @@ Q_OUTOFLINE_TEMPLATE QList<T> &QList<T>::operator+=(const QList<T> &l)
|
|||
} else {
|
||||
Node *n = (d->ref != 1)
|
||||
? detach_helper_grow(INT_MAX, l.size())
|
||||
: reinterpret_cast<Node *>(p.append2(l.p));
|
||||
: reinterpret_cast<Node *>(p.append(l.p));
|
||||
QT_TRY {
|
||||
node_copy(n, reinterpret_cast<Node *>(p.end()),
|
||||
reinterpret_cast<Node *>(l.p.begin()));
|
||||
|
|
|
@ -85,7 +85,7 @@ void QMapData::continueFreeData(int offset)
|
|||
if (strictAlignment)
|
||||
qFreeAligned(reinterpret_cast<char *>(prev) - offset);
|
||||
else
|
||||
qFree(reinterpret_cast<char *>(prev) - offset);
|
||||
free(reinterpret_cast<char *>(prev) - offset);
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ QMapData::Node *QMapData::node_create(Node *update[], int offset, int alignment)
|
|||
|
||||
void *concreteNode = strictAlignment ?
|
||||
qMallocAligned(offset + sizeof(Node) + level * sizeof(Node *), alignment) :
|
||||
qMalloc(offset + sizeof(Node) + level * sizeof(Node *));
|
||||
malloc(offset + sizeof(Node) + level * sizeof(Node *));
|
||||
Q_CHECK_PTR(concreteNode);
|
||||
|
||||
Node *abstractNode = reinterpret_cast<Node *>(reinterpret_cast<char *>(concreteNode) + offset);
|
||||
|
@ -157,7 +157,7 @@ void QMapData::node_delete(Node *update[], int offset, Node *node)
|
|||
if (strictAlignment)
|
||||
qFreeAligned(reinterpret_cast<char *>(node) - offset);
|
||||
else
|
||||
qFree(reinterpret_cast<char *>(node) - offset);
|
||||
free(reinterpret_cast<char *>(node) - offset);
|
||||
}
|
||||
|
||||
#ifdef QT_QMAP_DEBUG
|
||||
|
|
|
@ -79,7 +79,7 @@ struct QScopedPointerArrayDeleter
|
|||
|
||||
struct QScopedPointerPodDeleter
|
||||
{
|
||||
static inline void cleanup(void *pointer) { if (pointer) qFree(pointer); }
|
||||
static inline void cleanup(void *pointer) { if (pointer) free(pointer); }
|
||||
};
|
||||
|
||||
template <typename T, typename Cleanup = QScopedPointerDeleter<T> >
|
||||
|
|
|
@ -1049,7 +1049,7 @@ QString::QString(const QChar *unicode, int size)
|
|||
d = &shared_empty;
|
||||
d->ref.ref();
|
||||
} else {
|
||||
d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
|
||||
d = (Data*) malloc(sizeof(Data)+size*sizeof(QChar));
|
||||
Q_CHECK_PTR(d);
|
||||
d->ref = 1;
|
||||
d->alloc = d->size = size;
|
||||
|
@ -1082,7 +1082,7 @@ QString::QString(const QChar *unicode)
|
|||
d = &shared_empty;
|
||||
d->ref.ref();
|
||||
} else {
|
||||
d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
|
||||
d = (Data*) malloc(sizeof(Data)+size*sizeof(QChar));
|
||||
Q_CHECK_PTR(d);
|
||||
d->ref = 1;
|
||||
d->alloc = d->size = size;
|
||||
|
@ -1107,7 +1107,7 @@ QString::QString(int size, QChar ch)
|
|||
d = &shared_empty;
|
||||
d->ref.ref();
|
||||
} else {
|
||||
d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
|
||||
d = (Data*) malloc(sizeof(Data)+size*sizeof(QChar));
|
||||
Q_CHECK_PTR(d);
|
||||
d->ref = 1;
|
||||
d->alloc = d->size = size;
|
||||
|
@ -1130,7 +1130,7 @@ QString::QString(int size, QChar ch)
|
|||
*/
|
||||
QString::QString(int size, Qt::Initialization)
|
||||
{
|
||||
d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
|
||||
d = (Data*) malloc(sizeof(Data)+size*sizeof(QChar));
|
||||
Q_CHECK_PTR(d);
|
||||
d->ref = 1;
|
||||
d->alloc = d->size = size;
|
||||
|
@ -1151,7 +1151,7 @@ QString::QString(int size, Qt::Initialization)
|
|||
*/
|
||||
QString::QString(QChar ch)
|
||||
{
|
||||
void *buf = qMalloc(sizeof(Data) + sizeof(QChar));
|
||||
void *buf = malloc(sizeof(Data) + sizeof(QChar));
|
||||
Q_CHECK_PTR(buf);
|
||||
d = reinterpret_cast<Data *>(buf);
|
||||
d->ref = 1;
|
||||
|
@ -1214,10 +1214,9 @@ QString::QString(QChar ch)
|
|||
\internal
|
||||
*/
|
||||
|
||||
// ### Qt 5: rename freeData() to avoid confusion. See task 197625.
|
||||
void QString::free(Data *d)
|
||||
void QString::freeData(Data *d)
|
||||
{
|
||||
qFree(d);
|
||||
free(d);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -1259,12 +1258,12 @@ void QString::resize(int size)
|
|||
Data *x = &shared_empty;
|
||||
x->ref.ref();
|
||||
if (!d->ref.deref())
|
||||
QString::free(d);
|
||||
QString::freeData(d);
|
||||
d = x;
|
||||
} else {
|
||||
if (d->ref != 1 || size > d->alloc ||
|
||||
(!d->capacity && size < d->size && size < d->alloc >> 1))
|
||||
realloc(grow(size));
|
||||
reallocData(grow(size));
|
||||
if (d->alloc >= size) {
|
||||
d->size = size;
|
||||
if (d->data == d->array) {
|
||||
|
@ -1324,11 +1323,10 @@ void QString::resize(int size)
|
|||
\sa reserve(), capacity()
|
||||
*/
|
||||
|
||||
// ### Qt 5: rename reallocData() to avoid confusion. 197625
|
||||
void QString::realloc(int alloc)
|
||||
void QString::reallocData(int alloc)
|
||||
{
|
||||
if (d->ref != 1 || d->data != d->array) {
|
||||
Data *x = static_cast<Data *>(qMalloc(sizeof(Data) + alloc * sizeof(QChar)));
|
||||
Data *x = static_cast<Data *>(malloc(sizeof(Data) + alloc * sizeof(QChar)));
|
||||
Q_CHECK_PTR(x);
|
||||
x->size = qMin(alloc, d->size);
|
||||
::memcpy(x->array, d->data, x->size * sizeof(QChar));
|
||||
|
@ -1341,10 +1339,10 @@ void QString::realloc(int alloc)
|
|||
x->capacity = d->capacity;
|
||||
x->data = x->array;
|
||||
if (!d->ref.deref())
|
||||
QString::free(d);
|
||||
QString::freeData(d);
|
||||
d = x;
|
||||
} else {
|
||||
Data *p = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar)));
|
||||
Data *p = static_cast<Data *>(realloc(d, sizeof(Data) + alloc * sizeof(QChar)));
|
||||
Q_CHECK_PTR(p);
|
||||
d = p;
|
||||
d->alloc = alloc;
|
||||
|
@ -1352,9 +1350,9 @@ void QString::realloc(int alloc)
|
|||
}
|
||||
}
|
||||
|
||||
void QString::realloc()
|
||||
void QString::reallocData()
|
||||
{
|
||||
realloc(d->size);
|
||||
reallocData(d->size);
|
||||
}
|
||||
|
||||
void QString::expand(int i)
|
||||
|
@ -1386,7 +1384,7 @@ QString &QString::operator=(const QString &other)
|
|||
{
|
||||
other.d->ref.ref();
|
||||
if (!d->ref.deref())
|
||||
QString::free(d);
|
||||
QString::freeData(d);
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
@ -1502,11 +1500,11 @@ QString& QString::insert(int i, const QChar *unicode, int size)
|
|||
const ushort *s = (const ushort *)unicode;
|
||||
if (s >= d->data && s < d->data + d->alloc) {
|
||||
// Part of me - take a copy
|
||||
ushort *tmp = static_cast<ushort *>(qMalloc(size * sizeof(QChar)));
|
||||
ushort *tmp = static_cast<ushort *>(malloc(size * sizeof(QChar)));
|
||||
Q_CHECK_PTR(tmp);
|
||||
memcpy(tmp, s, size * sizeof(QChar));
|
||||
insert(i, reinterpret_cast<const QChar *>(tmp), size);
|
||||
qFree(tmp);
|
||||
free(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -1561,7 +1559,7 @@ QString &QString::append(const QString &str)
|
|||
operator=(str);
|
||||
} else {
|
||||
if (d->ref != 1 || d->size + str.d->size > d->alloc)
|
||||
realloc(grow(d->size + str.d->size));
|
||||
reallocData(grow(d->size + str.d->size));
|
||||
memcpy(d->data + d->size, str.d->data, str.d->size * sizeof(QChar));
|
||||
d->size += str.d->size;
|
||||
d->data[d->size] = '\0';
|
||||
|
@ -1581,7 +1579,7 @@ QString &QString::append(const QLatin1String &str)
|
|||
if (s) {
|
||||
int len = qstrlen((char *)s);
|
||||
if (d->ref != 1 || d->size + len > d->alloc)
|
||||
realloc(grow(d->size + len));
|
||||
reallocData(grow(d->size + len));
|
||||
ushort *i = d->data + d->size;
|
||||
while ((*i++ = *s++))
|
||||
;
|
||||
|
@ -1624,7 +1622,7 @@ QString &QString::append(const QLatin1String &str)
|
|||
QString &QString::append(QChar ch)
|
||||
{
|
||||
if (d->ref != 1 || d->size + 1 > d->alloc)
|
||||
realloc(grow(d->size + 1));
|
||||
reallocData(grow(d->size + 1));
|
||||
d->data[d->size++] = ch.unicode();
|
||||
d->data[d->size] = '\0';
|
||||
return *this;
|
||||
|
@ -1862,7 +1860,7 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar
|
|||
// (which we could possibly invalidate via a realloc or corrupt via memcpy operations.)
|
||||
QChar *afterBuffer = const_cast<QChar *>(after);
|
||||
if (after >= reinterpret_cast<QChar *>(d->data) && after < reinterpret_cast<QChar *>(d->data) + d->size) {
|
||||
afterBuffer = static_cast<QChar *>(qMalloc(alen*sizeof(QChar)));
|
||||
afterBuffer = static_cast<QChar *>(malloc(alen*sizeof(QChar)));
|
||||
Q_CHECK_PTR(afterBuffer);
|
||||
::memcpy(afterBuffer, after, alen*sizeof(QChar));
|
||||
}
|
||||
|
@ -1917,11 +1915,11 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar
|
|||
}
|
||||
} QT_CATCH(const std::bad_alloc &) {
|
||||
if (afterBuffer != after)
|
||||
qFree(afterBuffer);
|
||||
free(afterBuffer);
|
||||
QT_RETHROW;
|
||||
}
|
||||
if (afterBuffer != after)
|
||||
qFree(afterBuffer);
|
||||
free(afterBuffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -2824,7 +2822,7 @@ QString& QString::replace(const QRegExp &rx, const QString &after)
|
|||
if (isEmpty() && rx2.indexIn(*this) == -1)
|
||||
return *this;
|
||||
|
||||
realloc();
|
||||
reallocData();
|
||||
|
||||
int index = 0;
|
||||
int numCaptures = rx2.captureCount();
|
||||
|
@ -3801,7 +3799,7 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size)
|
|||
} else {
|
||||
if (size < 0)
|
||||
size = qstrlen(str);
|
||||
d = static_cast<Data *>(qMalloc(sizeof(Data) + size * sizeof(QChar)));
|
||||
d = static_cast<Data *>(malloc(sizeof(Data) + size * sizeof(QChar)));
|
||||
Q_CHECK_PTR(d);
|
||||
d->ref = 1;
|
||||
d->alloc = d->size = size;
|
||||
|
@ -4855,7 +4853,7 @@ const ushort *QString::utf16() const
|
|||
{
|
||||
if (d->data != d->array) {
|
||||
QString *that = const_cast<QString*>(this);
|
||||
that->realloc(); // ensure '\\0'-termination for ::fromRawData strings
|
||||
that->reallocData(); // ensure '\\0'-termination for ::fromRawData strings
|
||||
return that->d->data;
|
||||
}
|
||||
return d->array;
|
||||
|
@ -7134,7 +7132,7 @@ bool QString::isRightToLeft() const
|
|||
*/
|
||||
QString QString::fromRawData(const QChar *unicode, int size)
|
||||
{
|
||||
Data *x = static_cast<Data *>(qMalloc(sizeof(Data)));
|
||||
Data *x = static_cast<Data *>(malloc(sizeof(Data)));
|
||||
Q_CHECK_PTR(x);
|
||||
if (unicode) {
|
||||
x->data = (ushort *)unicode;
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
|
||||
int capacity() const;
|
||||
inline void reserve(int size);
|
||||
inline void squeeze() { if (d->size < d->alloc || d->ref != 1) realloc(); d->capacity = 0;}
|
||||
inline void squeeze() { if (d->size < d->alloc || d->ref != 1) reallocData(); d->capacity = 0;}
|
||||
|
||||
inline const QChar *unicode() const;
|
||||
inline QChar *data();
|
||||
|
@ -260,7 +260,7 @@ public:
|
|||
|
||||
inline QString &operator+=(QChar c) {
|
||||
if (d->ref != 1 || d->size + 1 > d->alloc)
|
||||
realloc(grow(d->size + 1));
|
||||
reallocData(grow(d->size + 1));
|
||||
d->data[d->size++] = c.unicode();
|
||||
d->data[d->size] = '\0';
|
||||
return *this;
|
||||
|
@ -526,9 +526,9 @@ private:
|
|||
static QTextCodec *codecForCStrings;
|
||||
#endif
|
||||
static int grow(int);
|
||||
static void free(Data *);
|
||||
void realloc();
|
||||
void realloc(int alloc);
|
||||
static void freeData(Data *);
|
||||
void reallocData();
|
||||
void reallocData(int alloc);
|
||||
void expand(int i);
|
||||
void updateProperties() const;
|
||||
QString multiArg(int numArgs, const QString **args) const;
|
||||
|
@ -617,7 +617,7 @@ inline QChar *QString::data()
|
|||
inline const QChar *QString::constData() const
|
||||
{ return reinterpret_cast<const QChar*>(d->data); }
|
||||
inline void QString::detach()
|
||||
{ if (d->ref != 1 || d->data != d->array) realloc(); }
|
||||
{ if (d->ref != 1 || d->data != d->array) reallocData(); }
|
||||
inline bool QString::isDetached() const
|
||||
{ return d->ref == 1; }
|
||||
inline QString &QString::operator=(const QLatin1String &s)
|
||||
|
@ -770,8 +770,8 @@ inline void QCharRef::setCell(uchar acell) { QChar(*this).setCell(acell); }
|
|||
|
||||
|
||||
inline QString::QString() : d(&shared_null) { d->ref.ref(); }
|
||||
inline QString::~QString() { if (!d->ref.deref()) free(d); }
|
||||
inline void QString::reserve(int asize) { if (d->ref != 1 || asize > d->alloc) realloc(asize); d->capacity = 1;}
|
||||
inline QString::~QString() { if (!d->ref.deref()) freeData(d); }
|
||||
inline void QString::reserve(int asize) { if (d->ref != 1 || asize > d->alloc) reallocData(asize); d->capacity = 1;}
|
||||
inline QString &QString::setUtf16(const ushort *autf16, int asize)
|
||||
{ return setUnicode(reinterpret_cast<const QChar *>(autf16), asize); }
|
||||
inline QCharRef QString::operator[](int i)
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
i->~T();
|
||||
}
|
||||
if (ptr != reinterpret_cast<T *>(array))
|
||||
qFree(ptr);
|
||||
free(ptr);
|
||||
}
|
||||
inline QVarLengthArray<T, Prealloc> &operator=(const QVarLengthArray<T, Prealloc> &other)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ template <class T, int Prealloc>
|
|||
Q_INLINE_TEMPLATE QVarLengthArray<T, Prealloc>::QVarLengthArray(int asize)
|
||||
: s(asize) {
|
||||
if (s > Prealloc) {
|
||||
ptr = reinterpret_cast<T *>(qMalloc(s * sizeof(T)));
|
||||
ptr = reinterpret_cast<T *>(malloc(s * sizeof(T)));
|
||||
Q_CHECK_PTR(ptr);
|
||||
a = s;
|
||||
} else {
|
||||
|
@ -234,7 +234,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
|
|||
|
||||
const int copySize = qMin(asize, osize);
|
||||
if (aalloc != a) {
|
||||
ptr = reinterpret_cast<T *>(qMalloc(aalloc * sizeof(T)));
|
||||
ptr = reinterpret_cast<T *>(malloc(aalloc * sizeof(T)));
|
||||
Q_CHECK_PTR(ptr);
|
||||
if (ptr) {
|
||||
s = 0;
|
||||
|
@ -254,7 +254,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
|
|||
while (sClean < osize)
|
||||
(oldPtr+(sClean++))->~T();
|
||||
if (oldPtr != reinterpret_cast<T *>(array) && oldPtr != ptr)
|
||||
qFree(oldPtr);
|
||||
free(oldPtr);
|
||||
QT_RETHROW;
|
||||
}
|
||||
} else {
|
||||
|
@ -274,7 +274,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
|
|||
}
|
||||
|
||||
if (oldPtr != reinterpret_cast<T *>(array) && oldPtr != ptr)
|
||||
qFree(oldPtr);
|
||||
free(oldPtr);
|
||||
|
||||
if (QTypeInfo<T>::isComplex) {
|
||||
// call default constructor for new objects (which can throw)
|
||||
|
|
|
@ -54,32 +54,24 @@ static inline int alignmentThreshold()
|
|||
|
||||
QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false, 0 };
|
||||
|
||||
QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init)
|
||||
{
|
||||
QVectorData* p = (QVectorData *)qMalloc(sizeofTypedData + (size - 1) * sizeofT);
|
||||
Q_CHECK_PTR(p);
|
||||
::memcpy(p, init, sizeofTypedData + (qMin(size, init->alloc) - 1) * sizeofT);
|
||||
return p;
|
||||
}
|
||||
|
||||
QVectorData *QVectorData::allocate(int size, int alignment)
|
||||
{
|
||||
return static_cast<QVectorData *>(alignment > alignmentThreshold() ? qMallocAligned(size, alignment) : qMalloc(size));
|
||||
return static_cast<QVectorData *>(alignment > alignmentThreshold() ? qMallocAligned(size, alignment) : malloc(size));
|
||||
}
|
||||
|
||||
QVectorData *QVectorData::reallocate(QVectorData *x, int newsize, int oldsize, int alignment)
|
||||
{
|
||||
if (alignment > alignmentThreshold())
|
||||
return static_cast<QVectorData *>(qReallocAligned(x, newsize, oldsize, alignment));
|
||||
return static_cast<QVectorData *>(qRealloc(x, newsize));
|
||||
return static_cast<QVectorData *>(realloc(x, newsize));
|
||||
}
|
||||
|
||||
void QVectorData::free(QVectorData *x, int alignment)
|
||||
void QVectorData::freeData(QVectorData *x, int alignment)
|
||||
{
|
||||
if (alignment > alignmentThreshold())
|
||||
qFreeAligned(x);
|
||||
else
|
||||
qFree(x);
|
||||
free(x);
|
||||
}
|
||||
|
||||
int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive)
|
||||
|
|
|
@ -69,13 +69,9 @@ struct Q_CORE_EXPORT QVectorData
|
|||
#endif
|
||||
|
||||
static QVectorData shared_null;
|
||||
// ### Qt 5: rename to 'allocate()'. The current name causes problems for
|
||||
// some debugges when the QVector is member of a class within an unnamed namespace.
|
||||
// ### Qt 5: can be removed completely. (Ralf)
|
||||
static QVectorData *malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init);
|
||||
static QVectorData *allocate(int size, int alignment);
|
||||
static QVectorData *reallocate(QVectorData *old, int newsize, int oldsize, int alignment);
|
||||
static void free(QVectorData *data, int alignment);
|
||||
static void freeData(QVectorData *data, int alignment);
|
||||
static int grow(int sizeofTypedData, int size, int sizeofT, bool excessive);
|
||||
};
|
||||
|
||||
|
@ -85,7 +81,7 @@ struct QVectorTypedData : private QVectorData
|
|||
// as this would break strict aliasing rules. (in the case of shared_null)
|
||||
T array[1];
|
||||
|
||||
static inline void free(QVectorTypedData<T> *x, int alignment) { QVectorData::free(static_cast<QVectorData *>(x), alignment); }
|
||||
static inline void free(QVectorTypedData<T> *x, int alignment) { QVectorData::freeData(static_cast<QVectorData *>(x), alignment); }
|
||||
};
|
||||
|
||||
class QRegion;
|
||||
|
|
|
@ -891,9 +891,9 @@ void QXmlStreamReaderPrivate::parseEntity(const QString &value)
|
|||
inline void QXmlStreamReaderPrivate::reallocateStack()
|
||||
{
|
||||
stack_size <<= 1;
|
||||
sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
|
||||
sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
|
||||
Q_CHECK_PTR(sym_stack);
|
||||
state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
|
||||
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
|
||||
Q_CHECK_PTR(sym_stack);
|
||||
}
|
||||
|
||||
|
@ -903,8 +903,8 @@ QXmlStreamReaderPrivate::~QXmlStreamReaderPrivate()
|
|||
#ifndef QT_NO_TEXTCODEC
|
||||
delete decoder;
|
||||
#endif
|
||||
qFree(sym_stack);
|
||||
qFree(state_stack);
|
||||
free(sym_stack);
|
||||
free(state_stack);
|
||||
delete entityParser;
|
||||
}
|
||||
|
||||
|
|
|
@ -152,12 +152,12 @@ template <typename T> class QXmlStreamSimpleStack {
|
|||
int tos, cap;
|
||||
public:
|
||||
inline QXmlStreamSimpleStack():data(0), tos(-1), cap(0){}
|
||||
inline ~QXmlStreamSimpleStack(){ if (data) qFree(data); }
|
||||
inline ~QXmlStreamSimpleStack(){ if (data) free(data); }
|
||||
|
||||
inline void reserve(int extraCapacity) {
|
||||
if (tos + extraCapacity + 1 > cap) {
|
||||
cap = qMax(tos + extraCapacity + 1, cap << 1 );
|
||||
data = reinterpret_cast<T *>(qRealloc(data, cap * sizeof(T)));
|
||||
data = reinterpret_cast<T *>(realloc(data, cap * sizeof(T)));
|
||||
Q_CHECK_PTR(data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -646,12 +646,12 @@ template <typename T> class QXmlStreamSimpleStack {
|
|||
int tos, cap;
|
||||
public:
|
||||
inline QXmlStreamSimpleStack():data(0), tos(-1), cap(0){}
|
||||
inline ~QXmlStreamSimpleStack(){ if (data) qFree(data); }
|
||||
inline ~QXmlStreamSimpleStack(){ if (data) free(data); }
|
||||
|
||||
inline void reserve(int extraCapacity) {
|
||||
if (tos + extraCapacity + 1 > cap) {
|
||||
cap = qMax(tos + extraCapacity + 1, cap << 1 );
|
||||
data = reinterpret_cast<T *>(qRealloc(data, cap * sizeof(T)));
|
||||
data = reinterpret_cast<T *>(realloc(data, cap * sizeof(T)));
|
||||
Q_CHECK_PTR(data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -393,9 +393,9 @@ void Parser::reallocateStack()
|
|||
else
|
||||
stack_size <<= 1;
|
||||
|
||||
sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
|
||||
state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<AST::SourceLocation*> (qRealloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
|
||||
sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
|
||||
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
|
||||
}
|
||||
|
||||
inline static bool automatic(Engine *driver, int token)
|
||||
|
@ -421,9 +421,9 @@ Parser::Parser(Engine *engine):
|
|||
Parser::~Parser()
|
||||
{
|
||||
if (stack_size) {
|
||||
qFree(sym_stack);
|
||||
qFree(state_stack);
|
||||
qFree(location_stack);
|
||||
free(sym_stack);
|
||||
free(state_stack);
|
||||
free(location_stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,9 +78,9 @@ public:
|
|||
|
||||
virtual ~MemoryPool() {
|
||||
for (int index = 0; index < m_blockIndex + 1; ++index)
|
||||
qFree(m_storage[index]);
|
||||
free(m_storage[index]);
|
||||
|
||||
qFree(m_storage);
|
||||
free(m_storage);
|
||||
}
|
||||
|
||||
char *allocate(int bytes) {
|
||||
|
@ -89,8 +89,8 @@ public:
|
|||
++m_blockIndex;
|
||||
m_currentBlockSize = defaultBlockSize << m_blockIndex;
|
||||
|
||||
m_storage = reinterpret_cast<char**>(qRealloc(m_storage, sizeof(char*) * (1 + m_blockIndex)));
|
||||
m_currentBlock = m_storage[m_blockIndex] = reinterpret_cast<char*>(qMalloc(m_currentBlockSize));
|
||||
m_storage = reinterpret_cast<char**>(realloc(m_storage, sizeof(char*) * (1 + m_blockIndex)));
|
||||
m_currentBlock = m_storage[m_blockIndex] = reinterpret_cast<char*>(malloc(m_currentBlockSize));
|
||||
::memset(m_currentBlock, 0, m_currentBlockSize);
|
||||
|
||||
m_currentIndex = (8 - quintptr(m_currentBlock)) & 7; // ensure first chunk is 64-bit aligned
|
||||
|
|
|
@ -70,9 +70,9 @@ void Parser::reallocateStack()
|
|||
else
|
||||
stack_size <<= 1;
|
||||
|
||||
sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
|
||||
state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<AST::SourceLocation*> (qRealloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
|
||||
sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
|
||||
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
|
||||
}
|
||||
|
||||
inline static bool automatic(Engine *driver, int token)
|
||||
|
@ -98,9 +98,9 @@ Parser::Parser(Engine *engine):
|
|||
Parser::~Parser()
|
||||
{
|
||||
if (stack_size) {
|
||||
qFree(sym_stack);
|
||||
qFree(state_stack);
|
||||
qFree(location_stack);
|
||||
free(sym_stack);
|
||||
free(state_stack);
|
||||
free(location_stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMeta
|
|||
QDeclarativeBoundSignalParameters::~QDeclarativeBoundSignalParameters()
|
||||
{
|
||||
delete [] types;
|
||||
qFree(myMetaObject);
|
||||
free(myMetaObject);
|
||||
}
|
||||
|
||||
void QDeclarativeBoundSignalParameters::setValues(void **v)
|
||||
|
|
|
@ -1378,7 +1378,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||
QMetaObject *QMetaObjectBuilder::toMetaObject() const
|
||||
{
|
||||
int size = buildMetaObject(d, 0, false);
|
||||
char *buf = reinterpret_cast<char *>(qMalloc(size));
|
||||
char *buf = reinterpret_cast<char *>(malloc(size));
|
||||
memset(buf, 0, size);
|
||||
buildMetaObject(d, buf, false);
|
||||
return reinterpret_cast<QMetaObject *>(buf);
|
||||
|
|
|
@ -75,7 +75,7 @@ QDeclarativeOpenMetaObjectType::QDeclarativeOpenMetaObjectType(const QMetaObject
|
|||
QDeclarativeOpenMetaObjectType::~QDeclarativeOpenMetaObjectType()
|
||||
{
|
||||
if (d->mem)
|
||||
qFree(d->mem);
|
||||
free(d->mem);
|
||||
if (d->cache)
|
||||
d->cache->release();
|
||||
delete d;
|
||||
|
@ -98,7 +98,7 @@ int QDeclarativeOpenMetaObjectType::createProperty(const QByteArray &name)
|
|||
d->mob.addSignal("__" + QByteArray::number(id) + "()");
|
||||
QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
|
||||
propertyCreated(id, build);
|
||||
qFree(d->mem);
|
||||
free(d->mem);
|
||||
d->mem = d->mob.toMetaObject();
|
||||
d->names.insert(name, id);
|
||||
QSet<QDeclarativeOpenMetaObject*>::iterator it = d->referers.begin();
|
||||
|
|
|
@ -202,7 +202,7 @@ QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
|
|||
|
||||
QImage result;
|
||||
// Get bitmap bits
|
||||
uchar *data = (uchar *) qMalloc(bmi.bmiHeader.biSizeImage);
|
||||
uchar *data = (uchar *) malloc(bmi.bmiHeader.biSizeImage);
|
||||
|
||||
HDC display_dc = GetDC(0);
|
||||
if (GetDIBits(display_dc, bitmap, 0, h, data, &bmi, DIB_RGB_COLORS)) {
|
||||
|
@ -235,7 +235,7 @@ QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
|
|||
qWarning("QPixmap::fromWinHBITMAP(), failed to get bitmap bits");
|
||||
}
|
||||
ReleaseDC(0, display_dc);
|
||||
qFree(data);
|
||||
free(data);
|
||||
return fromImage(result);
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ static QImage qt_fromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
|
|||
return image;
|
||||
|
||||
// Get bitmap bits
|
||||
uchar *data = (uchar *) qMalloc(bmi.bmiHeader.biSizeImage);
|
||||
uchar *data = (uchar *) malloc(bmi.bmiHeader.biSizeImage);
|
||||
|
||||
if (GetDIBits(hdc, bitmap, 0, h, data, &bmi, DIB_RGB_COLORS)) {
|
||||
// Create image and copy data into image.
|
||||
|
@ -309,7 +309,7 @@ static QImage qt_fromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
|
|||
} else {
|
||||
qWarning("qt_fromWinHBITMAP(), failed to get bitmap bits");
|
||||
}
|
||||
qFree(data);
|
||||
free(data);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
|
|
@ -503,13 +503,13 @@ bool QTiffHandler::write(const QImage &image)
|
|||
}
|
||||
//// write the color table
|
||||
// allocate the color tables
|
||||
uint16 *redTable = static_cast<uint16 *>(qMalloc(256 * sizeof(uint16)));
|
||||
uint16 *greenTable = static_cast<uint16 *>(qMalloc(256 * sizeof(uint16)));
|
||||
uint16 *blueTable = static_cast<uint16 *>(qMalloc(256 * sizeof(uint16)));
|
||||
uint16 *redTable = static_cast<uint16 *>(malloc(256 * sizeof(uint16)));
|
||||
uint16 *greenTable = static_cast<uint16 *>(malloc(256 * sizeof(uint16)));
|
||||
uint16 *blueTable = static_cast<uint16 *>(malloc(256 * sizeof(uint16)));
|
||||
if (!redTable || !greenTable || !blueTable) {
|
||||
qFree(redTable);
|
||||
qFree(greenTable);
|
||||
qFree(blueTable);
|
||||
free(redTable);
|
||||
free(greenTable);
|
||||
free(blueTable);
|
||||
TIFFClose(tiff);
|
||||
return false;
|
||||
}
|
||||
|
@ -526,9 +526,9 @@ bool QTiffHandler::write(const QImage &image)
|
|||
|
||||
const bool setColorTableSuccess = TIFFSetField(tiff, TIFFTAG_COLORMAP, redTable, greenTable, blueTable);
|
||||
|
||||
qFree(redTable);
|
||||
qFree(greenTable);
|
||||
qFree(blueTable);
|
||||
free(redTable);
|
||||
free(greenTable);
|
||||
free(blueTable);
|
||||
|
||||
if (!setColorTableSuccess) {
|
||||
TIFFClose(tiff);
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
{
|
||||
capacity = res;
|
||||
if (res)
|
||||
buffer = (Type*) qMalloc(capacity * sizeof(Type));
|
||||
buffer = (Type*) malloc(capacity * sizeof(Type));
|
||||
else
|
||||
buffer = 0;
|
||||
siz = 0;
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
~QDataBuffer()
|
||||
{
|
||||
if (buffer)
|
||||
qFree(buffer);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
inline void reset() { siz = 0; }
|
||||
|
@ -112,16 +112,16 @@ public:
|
|||
capacity = 1;
|
||||
while (capacity < size)
|
||||
capacity *= 2;
|
||||
buffer = (Type*) qRealloc(buffer, capacity * sizeof(Type));
|
||||
buffer = (Type*) realloc(buffer, capacity * sizeof(Type));
|
||||
}
|
||||
}
|
||||
|
||||
inline void shrink(int size) {
|
||||
capacity = size;
|
||||
if (size)
|
||||
buffer = (Type*) qRealloc(buffer, capacity * sizeof(Type));
|
||||
buffer = (Type*) realloc(buffer, capacity * sizeof(Type));
|
||||
else {
|
||||
qFree(buffer);
|
||||
free(buffer);
|
||||
buffer = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes,
|
|||
QSGGeometry::~QSGGeometry()
|
||||
{
|
||||
if (m_owns_data)
|
||||
qFree(m_data);
|
||||
free(m_data);
|
||||
}
|
||||
|
||||
void *QSGGeometry::indexData()
|
||||
|
@ -135,7 +135,7 @@ void QSGGeometry::allocate(int vertexCount, int indexCount)
|
|||
int vertexByteSize = m_attributes.stride * m_vertex_count;
|
||||
|
||||
if (m_owns_data)
|
||||
qFree(m_data);
|
||||
free(m_data);
|
||||
|
||||
if (canUsePrealloc && vertexByteSize <= (int) sizeof(m_prealloc)) {
|
||||
m_data = (void *) &m_prealloc[0];
|
||||
|
@ -144,7 +144,7 @@ void QSGGeometry::allocate(int vertexCount, int indexCount)
|
|||
} else {
|
||||
Q_ASSERT(m_index_type == GL_UNSIGNED_INT || m_index_type == GL_UNSIGNED_SHORT);
|
||||
int indexByteSize = indexCount * (m_index_type == GL_UNSIGNED_SHORT ? sizeof(quint16) : sizeof(quint32));
|
||||
m_data = (void *) qMalloc(vertexByteSize + indexByteSize);
|
||||
m_data = (void *) malloc(vertexByteSize + indexByteSize);
|
||||
m_index_data_offset = vertexByteSize;
|
||||
m_owns_data = true;
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ QList<int> QAudioDeviceInfoInternal::channelsList()
|
|||
&propSize,
|
||||
0) == noErr) {
|
||||
|
||||
AudioBufferList* audioBufferList = static_cast<AudioBufferList*>(qMalloc(propSize));
|
||||
AudioBufferList* audioBufferList = static_cast<AudioBufferList*>(malloc(propSize));
|
||||
|
||||
if (audioBufferList != 0) {
|
||||
if (AudioDeviceGetProperty(deviceId,
|
||||
|
@ -247,7 +247,7 @@ QList<int> QAudioDeviceInfoInternal::channelsList()
|
|||
}
|
||||
}
|
||||
|
||||
qFree(audioBufferList);
|
||||
free(audioBufferList);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
|
||||
dataSize = 0;
|
||||
|
||||
bfs = reinterpret_cast<AudioBufferList*>(qMalloc(sizeof(AudioBufferList) +
|
||||
bfs = reinterpret_cast<AudioBufferList*>(malloc(sizeof(AudioBufferList) +
|
||||
(sizeof(AudioBuffer) * numberOfBuffers)));
|
||||
|
||||
bfs->mNumberBuffers = numberOfBuffers;
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
{
|
||||
dataSize = bufferSize;
|
||||
|
||||
bfs = reinterpret_cast<AudioBufferList*>(qMalloc(sizeof(AudioBufferList) + sizeof(AudioBuffer)));
|
||||
bfs = reinterpret_cast<AudioBufferList*>(malloc(sizeof(AudioBufferList) + sizeof(AudioBuffer)));
|
||||
|
||||
bfs->mNumberBuffers = 1;
|
||||
bfs->mBuffers[0].mNumberChannels = 1;
|
||||
|
@ -116,13 +116,13 @@ public:
|
|||
|
||||
dataSize = framesToBuffer * sf.mBytesPerFrame;
|
||||
|
||||
bfs = reinterpret_cast<AudioBufferList*>(qMalloc(sizeof(AudioBufferList) +
|
||||
bfs = reinterpret_cast<AudioBufferList*>(malloc(sizeof(AudioBufferList) +
|
||||
(sizeof(AudioBuffer) * numberOfBuffers)));
|
||||
bfs->mNumberBuffers = numberOfBuffers;
|
||||
for (int i = 0; i < numberOfBuffers; ++i) {
|
||||
bfs->mBuffers[i].mNumberChannels = isInterleaved ? numberOfBuffers : 1;
|
||||
bfs->mBuffers[i].mDataByteSize = dataSize;
|
||||
bfs->mBuffers[i].mData = qMalloc(dataSize);
|
||||
bfs->mBuffers[i].mData = malloc(dataSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,10 +130,10 @@ public:
|
|||
{
|
||||
if (owner) {
|
||||
for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i)
|
||||
qFree(bfs->mBuffers[i].mData);
|
||||
free(bfs->mBuffers[i].mData);
|
||||
}
|
||||
|
||||
qFree(bfs);
|
||||
free(bfs);
|
||||
}
|
||||
|
||||
AudioBufferList* audioBufferList() const
|
||||
|
|
|
@ -336,7 +336,7 @@ QString QHostInfo::localDomainName()
|
|||
resolveLibrary();
|
||||
if (local_res_ninit) {
|
||||
// using thread-safe version
|
||||
res_state_ptr state = res_state_ptr(qMalloc(sizeof(*state)));
|
||||
res_state_ptr state = res_state_ptr(malloc(sizeof(*state)));
|
||||
Q_CHECK_PTR(state);
|
||||
memset(state, 0, sizeof(*state));
|
||||
local_res_ninit(state);
|
||||
|
@ -344,7 +344,7 @@ QString QHostInfo::localDomainName()
|
|||
if (domainName.isEmpty())
|
||||
domainName = QUrl::fromAce(state->dnsrch[0]);
|
||||
local_res_nclose(state);
|
||||
qFree(state);
|
||||
free(state);
|
||||
|
||||
return domainName;
|
||||
}
|
||||
|
|
|
@ -104,12 +104,12 @@ static QHash<QHostAddress, QHostAddress> ipv4Netmasks()
|
|||
DWORD retval = ptrGetAdaptersInfo(pAdapter, &bufSize);
|
||||
if (retval == ERROR_BUFFER_OVERFLOW) {
|
||||
// need more memory
|
||||
pAdapter = (IP_ADAPTER_INFO *)qMalloc(bufSize);
|
||||
pAdapter = (IP_ADAPTER_INFO *)malloc(bufSize);
|
||||
if (!pAdapter)
|
||||
return ipv4netmasks;
|
||||
// try again
|
||||
if (ptrGetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) {
|
||||
qFree(pAdapter);
|
||||
free(pAdapter);
|
||||
return ipv4netmasks;
|
||||
}
|
||||
} else if (retval != ERROR_SUCCESS) {
|
||||
|
@ -126,7 +126,7 @@ static QHash<QHostAddress, QHostAddress> ipv4Netmasks()
|
|||
}
|
||||
}
|
||||
if (pAdapter != staticBuf)
|
||||
qFree(pAdapter);
|
||||
free(pAdapter);
|
||||
|
||||
return ipv4netmasks;
|
||||
|
||||
|
@ -146,12 +146,12 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWinXP()
|
|||
ULONG retval = ptrGetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAdapter, &bufSize);
|
||||
if (retval == ERROR_BUFFER_OVERFLOW) {
|
||||
// need more memory
|
||||
pAdapter = (IP_ADAPTER_ADDRESSES *)qMalloc(bufSize);
|
||||
pAdapter = (IP_ADAPTER_ADDRESSES *)malloc(bufSize);
|
||||
if (!pAdapter)
|
||||
return interfaces;
|
||||
// try again
|
||||
if (ptrGetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAdapter, &bufSize) != ERROR_SUCCESS) {
|
||||
qFree(pAdapter);
|
||||
free(pAdapter);
|
||||
return interfaces;
|
||||
}
|
||||
} else if (retval != ERROR_SUCCESS) {
|
||||
|
@ -212,7 +212,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWinXP()
|
|||
}
|
||||
|
||||
if (pAdapter != staticBuf)
|
||||
qFree(pAdapter);
|
||||
free(pAdapter);
|
||||
|
||||
return interfaces;
|
||||
}
|
||||
|
@ -227,12 +227,12 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWin2k()
|
|||
DWORD retval = ptrGetAdaptersInfo(pAdapter, &bufSize);
|
||||
if (retval == ERROR_BUFFER_OVERFLOW) {
|
||||
// need more memory
|
||||
pAdapter = (IP_ADAPTER_INFO *)qMalloc(bufSize);
|
||||
pAdapter = (IP_ADAPTER_INFO *)malloc(bufSize);
|
||||
if (!pAdapter)
|
||||
return interfaces;
|
||||
// try again
|
||||
if (ptrGetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) {
|
||||
qFree(pAdapter);
|
||||
free(pAdapter);
|
||||
return interfaces;
|
||||
}
|
||||
} else if (retval != ERROR_SUCCESS) {
|
||||
|
@ -266,7 +266,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWin2k()
|
|||
}
|
||||
|
||||
if (pAdapter != staticBuf)
|
||||
qFree(pAdapter);
|
||||
free(pAdapter);
|
||||
|
||||
return interfaces;
|
||||
}
|
||||
|
@ -298,12 +298,12 @@ QString QHostInfo::localDomainName()
|
|||
ULONG bufSize = sizeof info;
|
||||
pinfo = &info;
|
||||
if (ptrGetNetworkParams(pinfo, &bufSize) == ERROR_BUFFER_OVERFLOW) {
|
||||
pinfo = (FIXED_INFO *)qMalloc(bufSize);
|
||||
pinfo = (FIXED_INFO *)malloc(bufSize);
|
||||
if (!pinfo)
|
||||
return QString();
|
||||
// try again
|
||||
if (ptrGetNetworkParams(pinfo, &bufSize) != ERROR_SUCCESS) {
|
||||
qFree(pinfo);
|
||||
free(pinfo);
|
||||
return QString(); // error
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ QString QHostInfo::localDomainName()
|
|||
QString domainName = QUrl::fromAce(pinfo->DomainName);
|
||||
|
||||
if (pinfo != &info)
|
||||
qFree(pinfo);
|
||||
free(pinfo);
|
||||
|
||||
return domainName;
|
||||
}
|
||||
|
|
|
@ -714,8 +714,8 @@ void QGL2PaintEngineExPrivate::cleanupVectorPath(QPaintEngineEx *engine, void *d
|
|||
d->unusedIBOSToClean << c->ibo;
|
||||
#else
|
||||
Q_UNUSED(engine);
|
||||
qFree(c->vertices);
|
||||
qFree(c->indices);
|
||||
free(c->vertices);
|
||||
free(c->indices);
|
||||
#endif
|
||||
delete c;
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
|
|||
cache->vbo = 0;
|
||||
Q_ASSERT(cache->ibo == 0);
|
||||
#else
|
||||
qFree(cache->vertices);
|
||||
free(cache->vertices);
|
||||
Q_ASSERT(cache->indices == 0);
|
||||
#endif
|
||||
updateCache = true;
|
||||
|
@ -788,7 +788,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
|
|||
glBufferData(GL_ARRAY_BUFFER, floatSizeInBytes, vertexCoordinateArray.data(), GL_STATIC_DRAW);
|
||||
cache->ibo = 0;
|
||||
#else
|
||||
cache->vertices = (float *) qMalloc(floatSizeInBytes);
|
||||
cache->vertices = (float *) malloc(floatSizeInBytes);
|
||||
memcpy(cache->vertices, vertexCoordinateArray.data(), floatSizeInBytes);
|
||||
cache->indices = 0;
|
||||
#endif
|
||||
|
@ -840,8 +840,8 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
|
|||
glDeleteBuffers(1, &cache->vbo);
|
||||
glDeleteBuffers(1, &cache->ibo);
|
||||
#else
|
||||
qFree(cache->vertices);
|
||||
qFree(cache->indices);
|
||||
free(cache->vertices);
|
||||
free(cache->indices);
|
||||
#endif
|
||||
updateCache = true;
|
||||
}
|
||||
|
@ -875,12 +875,12 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
|
|||
vertices[i] = float(inverseScale * polys.vertices.at(i));
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * vertices.size(), vertices.data(), GL_STATIC_DRAW);
|
||||
#else
|
||||
cache->vertices = (float *) qMalloc(sizeof(float) * polys.vertices.size());
|
||||
cache->vertices = (float *) malloc(sizeof(float) * polys.vertices.size());
|
||||
if (QGLExtensions::glExtensions() & QGLExtensions::ElementIndexUint) {
|
||||
cache->indices = (quint32 *) qMalloc(sizeof(quint32) * polys.indices.size());
|
||||
cache->indices = (quint32 *) malloc(sizeof(quint32) * polys.indices.size());
|
||||
memcpy(cache->indices, polys.indices.data(), sizeof(quint32) * polys.indices.size());
|
||||
} else {
|
||||
cache->indices = (quint16 *) qMalloc(sizeof(quint16) * polys.indices.size());
|
||||
cache->indices = (quint16 *) malloc(sizeof(quint16) * polys.indices.size());
|
||||
memcpy(cache->indices, polys.indices.data(), sizeof(quint16) * polys.indices.size());
|
||||
}
|
||||
for (int i = 0; i < polys.vertices.size(); ++i)
|
||||
|
|
|
@ -1042,7 +1042,7 @@ QScriptEnginePrivate::~QScriptEnginePrivate()
|
|||
while (freeScriptValues) {
|
||||
QScriptValuePrivate *p = freeScriptValues;
|
||||
freeScriptValues = p->next;
|
||||
qFree(p);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -610,7 +610,7 @@ inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(siz
|
|||
--freeScriptValuesCount;
|
||||
return p;
|
||||
}
|
||||
return reinterpret_cast<QScriptValuePrivate*>(qMalloc(size));
|
||||
return reinterpret_cast<QScriptValuePrivate*>(malloc(size));
|
||||
}
|
||||
|
||||
inline void QScriptEnginePrivate::freeScriptValuePrivate(QScriptValuePrivate *p)
|
||||
|
@ -620,7 +620,7 @@ inline void QScriptEnginePrivate::freeScriptValuePrivate(QScriptValuePrivate *p)
|
|||
freeScriptValues = p;
|
||||
++freeScriptValuesCount;
|
||||
} else {
|
||||
qFree(p);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -809,7 +809,7 @@ inline void* QScriptValuePrivate::operator new(size_t size, QScriptEnginePrivate
|
|||
{
|
||||
if (engine)
|
||||
return engine->allocateScriptValuePrivate(size);
|
||||
return qMalloc(size);
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
inline void QScriptValuePrivate::operator delete(void *ptr)
|
||||
|
@ -818,7 +818,7 @@ inline void QScriptValuePrivate::operator delete(void *ptr)
|
|||
if (d->engine)
|
||||
d->engine->freeScriptValuePrivate(d);
|
||||
else
|
||||
qFree(d);
|
||||
free(d);
|
||||
}
|
||||
|
||||
inline void QScriptEnginePrivate::saveException(JSC::ExecState *exec, JSC::JSValue *val)
|
||||
|
|
|
@ -268,9 +268,9 @@ inline void QScriptParser::reallocateStack()
|
|||
else
|
||||
stack_size <<= 1;
|
||||
|
||||
sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
|
||||
state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<Location*> (qRealloc(location_stack, stack_size * sizeof(Location)));
|
||||
sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
|
||||
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<Location*> (realloc(location_stack, stack_size * sizeof(Location)));
|
||||
}
|
||||
|
||||
:/
|
||||
|
@ -307,9 +307,9 @@ QScriptParser::QScriptParser():
|
|||
QScriptParser::~QScriptParser()
|
||||
{
|
||||
if (stack_size) {
|
||||
qFree(sym_stack);
|
||||
qFree(state_stack);
|
||||
qFree(location_stack);
|
||||
free(sym_stack);
|
||||
free(state_stack);
|
||||
free(location_stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,9 +84,9 @@ QScriptParser::QScriptParser():
|
|||
QScriptParser::~QScriptParser()
|
||||
{
|
||||
if (stack_size) {
|
||||
qFree(sym_stack);
|
||||
qFree(state_stack);
|
||||
qFree(location_stack);
|
||||
free(sym_stack);
|
||||
free(state_stack);
|
||||
free(location_stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,9 +149,9 @@ inline void QScriptParser::reallocateStack()
|
|||
else
|
||||
stack_size <<= 1;
|
||||
|
||||
sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
|
||||
state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<Location*> (qRealloc(location_stack, stack_size * sizeof(Location)));
|
||||
sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
|
||||
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<Location*> (realloc(location_stack, stack_size * sizeof(Location)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ SyntaxChecker::SyntaxChecker():
|
|||
SyntaxChecker::~SyntaxChecker()
|
||||
{
|
||||
if (stack_size) {
|
||||
qFree(state_stack);
|
||||
free(state_stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ inline void SyntaxChecker::reallocateStack()
|
|||
else
|
||||
stack_size <<= 1;
|
||||
|
||||
state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
|
||||
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
|
||||
}
|
||||
|
||||
} // namespace QScript
|
||||
|
|
|
@ -114,7 +114,7 @@ struct QTestCharBuffer
|
|||
inline ~QTestCharBuffer()
|
||||
{
|
||||
if (buf != staticBuf)
|
||||
qFree(buf);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
inline char *data()
|
||||
|
@ -142,10 +142,10 @@ struct QTestCharBuffer
|
|||
char *newBuf = 0;
|
||||
if (buf == staticBuf) {
|
||||
// if we point to our internal buffer, we need to malloc first
|
||||
newBuf = reinterpret_cast<char *>(qMalloc(newSize));
|
||||
newBuf = reinterpret_cast<char *>(malloc(newSize));
|
||||
} else {
|
||||
// if we already malloc'ed, just realloc
|
||||
newBuf = reinterpret_cast<char *>(qRealloc(buf, newSize));
|
||||
newBuf = reinterpret_cast<char *>(realloc(buf, newSize));
|
||||
}
|
||||
|
||||
// if the allocation went wrong (newBuf == 0), we leave the object as is
|
||||
|
|
|
@ -2162,8 +2162,8 @@ inline void QScriptParser::reallocateStack()
|
|||
stack_size <<= 1;
|
||||
|
||||
sym_stack.resize(stack_size);
|
||||
state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<Location*> (qRealloc(location_stack, stack_size * sizeof(Location)));
|
||||
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<Location*> (realloc(location_stack, stack_size * sizeof(Location)));
|
||||
}
|
||||
|
||||
inline static bool automatic(QScript::Lexer *lexer, int token)
|
||||
|
@ -2187,8 +2187,8 @@ QScriptParser::QScriptParser():
|
|||
QScriptParser::~QScriptParser()
|
||||
{
|
||||
if (stack_size) {
|
||||
qFree(state_stack);
|
||||
qFree(location_stack);
|
||||
free(state_stack);
|
||||
free(location_stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1479,8 +1479,8 @@ inline void QScriptParser::reallocateStack()
|
|||
stack_size <<= 1;
|
||||
|
||||
sym_stack.resize(stack_size);
|
||||
state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<Location*> (qRealloc(location_stack, stack_size * sizeof(Location)));
|
||||
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
|
||||
location_stack = reinterpret_cast<Location*> (realloc(location_stack, stack_size * sizeof(Location)));
|
||||
}
|
||||
|
||||
inline static bool automatic(QScript::Lexer *lexer, int token)
|
||||
|
@ -1504,8 +1504,8 @@ QScriptParser::QScriptParser():
|
|||
QScriptParser::~QScriptParser()
|
||||
{
|
||||
if (stack_size) {
|
||||
qFree(state_stack);
|
||||
qFree(location_stack);
|
||||
free(state_stack);
|
||||
free(location_stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue