#include <qconfig.h>
#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
#define QT_VERSION_STR "${KATIE_VERSION}"
/*
Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
/*
- These functions are for compatibility only
-*/
-Q_CORE_EXPORT_INLINE void *qMalloc(size_t size) { return ::malloc(size); }
-Q_CORE_EXPORT_INLINE void qFree(void *ptr) { ::free(ptr); }
-Q_CORE_EXPORT_INLINE void *qRealloc(void *ptr, size_t size) { return ::realloc(ptr, size); }
-Q_CORE_EXPORT_INLINE void *qMemCopy(void *dest, const void *src, size_t n) { return ::memcpy(dest, src, n); }
-Q_CORE_EXPORT_INLINE void *qMemSet(void *dest, int c, size_t n) { return ::memset(dest, c, n); }
-Q_CORE_EXPORT_INLINE void *qMallocAligned(size_t size, size_t alignment) { Q_UNUSED(alignment); return qMalloc(size); }
-Q_CORE_EXPORT_INLINE void qFreeAligned(void *ptr) { qFree(ptr); }
-Q_CORE_EXPORT_INLINE void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment)
-{
- Q_UNUSED(oldsize);
- Q_UNUSED(alignment);
- return qRealloc(ptr, size);
-}
-/*
These functions make it possible to use standard C++ functions with
a similar name from Qt header files (especially template classes).
*/
#include "qplatformdefs.h"
#include "qatomic.h"
-#ifndef Q_OS_UNIX
-# error "qcore_unix_p.h included on a non-Unix system"
-#endif
-
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-
#include <sys/wait.h>
#include <errno.h>
#include <fcntl.h>
-#if defined(Q_OS_VXWORKS)
-# include <ioLib.h>
-#endif
-
struct sockaddr;
#if defined(Q_OS_LINUX) && defined(O_CLOEXEC)
bufferCompleteSize += bd.size();
}
- // return the first QByteData. User of this function has to qFree() its .data!
+ // return the first QByteData. User of this function has to free() its .data!
// preferably use this function to read data.
inline QByteArray read()
{
return buffers.takeFirst();
}
- // return everything. User of this function has to qFree() its .data!
+ // return everything. User of this function has to free() its .data!
// avoid to use this, it might malloc and memcpy.
inline QByteArray readAll()
{
return read(bufferCompleteSize);
}
- // return amount. User of this function has to qFree() its .data!
+ // return amount. User of this function has to free() its .data!
// avoid to use this, it might malloc and memcpy.
inline QByteArray read(qint64 amount)
{
return byteData;
}
- // return amount bytes. User of this function has to qFree() its .data!
+ // return amount bytes. User of this function has to free() its .data!
// avoid to use this, it will memcpy.
qint64 read(char* dst, qint64 amount)
{
}
#endif
-QContiguousCacheData *QContiguousCacheData::allocate(int size, int alignment)
-{
- return static_cast<QContiguousCacheData *>(qMallocAligned(size, alignment));
-}
-
-void QContiguousCacheData::freeData(QContiguousCacheData *data)
-{
- qFreeAligned(data);
-}
-
/*! \class QContiguousCache
\brief The QContiguousCache class is a template class that provides a contiguous cache.
\ingroup tools
int offset;
uint sharable : 1;
- // total is 24 bytes (HP-UX aCC: 40 bytes)
- // the next entry is already aligned to 8 bytes
- // there will be an 8 byte gap here if T requires 16-byte alignment
- // (such as long double on 64-bit platforms, __int128, __float128)
-
- static QContiguousCacheData *allocate(int size, int alignment);
- static void freeData(QContiguousCacheData *data);
-
#ifdef QT_QCONTIGUOUSCACHE_DEBUG
void dump() const;
#endif
// private inheritance to avoid aliasing warningss
T array[1];
- static inline void free(QContiguousCacheTypedData *data) { QContiguousCacheData::freeData(data); }
+ static inline void free(QContiguousCacheTypedData *data) { ::free(data); }
};
template<typename T>
private:
void detach_helper();
- QContiguousCacheData *malloc(int aalloc);
+ QContiguousCacheData *allocate(int aalloc);
void free(Data *x);
int sizeOfTypedData() {
// this is more or less the same as sizeof(Data), except that it doesn't
// count the padding at the end
return reinterpret_cast<const char *>(&(reinterpret_cast<const Data *>(this))->array[1]) - reinterpret_cast<const char *>(this);
}
- int alignOfTypedData() const
- {
-#ifdef Q_ALIGNOF
- return qMax<int>(sizeof(void*), Q_ALIGNOF(Data));
-#else
- return 0;
-#endif
- }
};
template <typename T>
{
union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x;
- x.d = malloc(d->alloc);
+ x.d = allocate(d->alloc);
x.d->ref = 1;
x.d->count = d->count;
x.d->start = d->start;
return;
detach();
union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x;
- x.d = malloc(asize);
+ x.d = allocate(asize);
x.d->alloc = asize;
x.d->count = qMin(d->count, asize);
x.d->offset = d->offset + d->count - x.d->count;
d->count = d->start = d->offset = 0;
} else {
union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x;
- x.d = malloc(d->alloc);
+ x.d = allocate(d->alloc);
x.d->ref = 1;
x.d->alloc = d->alloc;
x.d->count = x.d->start = x.d->offset = 0;
}
template <typename T>
-inline QContiguousCacheData *QContiguousCache<T>::malloc(int aalloc)
+inline QContiguousCacheData *QContiguousCache<T>::allocate(int aalloc)
{
- return QContiguousCacheData::allocate(sizeOfTypedData() + (aalloc - 1) * sizeof(T), alignOfTypedData());
+ return ::malloc(sizeOfTypedData() + (aalloc - 1) * sizeof(T));
}
template <typename T>
QContiguousCache<T>::QContiguousCache(int cap)
{
- d = malloc(cap);
+ d = allocate(cap);
d->ref = 1;
d->alloc = cap;
d->count = d->start = d->offset = 0;
/*!
Converts this meta object builder into a concrete QMetaObject.
- The return value should be deallocated using qFree() once it
+ The return value should be deallocated using free() once it
is no longer needed.
The returned meta object is a snapshot of the state of the