// If you want to avoid the memcopy, you must write specializations for this function
template <typename T> inline void qToUnaligned(const T src, uchar *dest)
{
- qMemCopy(dest, &src, sizeof(T));
+ memcpy(dest, &src, sizeof(T));
}
/* T qFromLittleEndian(const uchar *src)
return p;
}
-#if defined(qMemCopy)
-# undef qMemCopy
-#endif
-#if defined(qMemSet)
-# undef qMemSet
-#endif
-
void *qMemCopy(void *dest, const void *src, size_t n) { return memcpy(dest, src, n); }
void *qMemSet(void *dest, int c, size_t n) { return memset(dest, c, n); }
Q_CORE_EXPORT QT_DEPRECATED void *qMalloc(size_t size) Q_ALLOC_SIZE(1);
Q_CORE_EXPORT QT_DEPRECATED void qFree(void *ptr);
Q_CORE_EXPORT QT_DEPRECATED void *qRealloc(void *ptr, size_t size) Q_ALLOC_SIZE(2);
+Q_CORE_EXPORT QT_DEPRECATED void *qMemCopy(void *dest, const void *src, size_t n);
+Q_CORE_EXPORT QT_DEPRECATED void *qMemSet(void *dest, int c, size_t n);
#endif
Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment) Q_ALLOC_SIZE(1);
Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment) Q_ALLOC_SIZE(2);
Q_CORE_EXPORT void qFreeAligned(void *ptr);
-Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
-Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
/*
# endif
#endif
-#if 0
-/* tell gcc to use its built-in methods for some common functions */
-#if defined(QT_NO_DEBUG) && defined(Q_CC_GNU)
-# define qMemCopy __builtin_memcpy
-# define qMemSet __builtin_memset
-#endif
-#endif
-
template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; }
template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }
: qt_le_inf_bytes);
union { unsigned char c[8]; double d; } returnValue;
- qMemCopy(returnValue.c, bytes, sizeof(returnValue.c));
+ memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
: qt_le_snan_bytes);
union { unsigned char c[8]; double d; } returnValue;
- qMemCopy(returnValue.c, bytes, sizeof(returnValue.c));
+ memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
: qt_le_qnan_bytes);
union { unsigned char c[8]; double d; } returnValue;
- qMemCopy(returnValue.c, bytes, sizeof(returnValue.c));
+ memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
if (colon > enum_name) {
int len = colon-enum_name-1;
scope_buffer = (char *)malloc(len+1);
- qMemCopy(scope_buffer, enum_name, len);
+ memcpy(scope_buffer, enum_name, len);
scope_buffer[len] = '\0';
scope_name = scope_buffer;
enum_name = colon+1;
{
p.p = 0;
p.l = 0;
- qMemSet(p.q_skiptable, 0, sizeof(p.q_skiptable));
+ memset(p.q_skiptable, 0, sizeof(p.q_skiptable));
}
/*!
inline int QString::toWCharArray(wchar_t *array) const
{
if (sizeof(wchar_t) == sizeof(QChar)) {
- qMemCopy(array, d->data(), sizeof(QChar) * size());
+ memcpy(array, d->data(), sizeof(QChar) * size());
return size();
}
return toUcs4_helper(d->data(), size(), reinterpret_cast<uint *>(array));
QStringMatcher::QStringMatcher()
: d_ptr(0), q_cs(Qt::CaseSensitive)
{
- qMemSet(q_data, 0, sizeof(q_data));
+ memset(q_data, 0, sizeof(q_data));
}
/*!
while (s < asize)
new (ptr+(s++)) T(*abuf++);
} else {
- qMemCopy(&ptr[s], abuf, increment * sizeof(T));
+ memcpy(&ptr[s], abuf, increment * sizeof(T));
s = asize;
}
}
QT_RETHROW;
}
} else {
- qMemCopy(ptr, oldPtr, copySize * sizeof(T));
+ memcpy(ptr, oldPtr, copySize * sizeof(T));
}
} else {
ptr = oldPtr;
while (i != b)
new (--i) T;
} else {
- qMemSet(d->begin(), 0, asize * sizeof(T));
+ memset(d->begin(), 0, asize * sizeof(T));
}
}
} else if (asize > x->size) {
// initialize newly allocated memory to 0
- qMemSet(x->end(), 0, (asize - x->size) * sizeof(T));
+ memset(x->end(), 0, (asize - x->size) * sizeof(T));
}
x->size = asize;
#include <QtGui/qcolor.h>
#include <QtGui/qevent.h>
+#include <stdlib.h>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
// quint64 alertHigh : 1;
State() {
- qMemSet(this, 0, sizeof(State));
+ memset(this, 0, sizeof(State));
}
};
if (d->state == QPngHandlerPrivate::ReadingEnd && !in->isSequential() && (in->size() - in->pos()) < 4 && length == 4) {
// Workaround for certain malformed PNGs that lack the final crc bytes
uchar endcrc[4] = { 0xae, 0x42, 0x60, 0x82 };
- qMemCopy(data, endcrc, 4);
+ memcpy(data, endcrc, 4);
in->seek(in->size());
return;
}
return;
png_textp text_ptr = new png_text[text.size()];
- qMemSet(text_ptr, 0, text.size() * sizeof(png_text));
+ memset(text_ptr, 0, text.size() * sizeof(png_text));
QMap<QString, QString>::ConstIterator it = text.constBegin();
int i = 0;
QVarLengthArray<QFixed, 128> advances(glyphCount);
QVarLengthArray<QGlyphJustification, 128> glyphJustifications(glyphCount);
QVarLengthArray<HB_GlyphAttributes, 128> glyphAttributes(glyphCount);
- qMemSet(glyphAttributes.data(), 0, glyphAttributes.size() * sizeof(HB_GlyphAttributes));
- qMemSet(advances.data(), 0, advances.size() * sizeof(QFixed));
- qMemSet(glyphJustifications.data(), 0, glyphJustifications.size() * sizeof(QGlyphJustification));
+ memset(glyphAttributes.data(), 0, glyphAttributes.size() * sizeof(HB_GlyphAttributes));
+ memset(advances.data(), 0, advances.size() * sizeof(QFixed));
+ memset(glyphJustifications.data(), 0, glyphJustifications.size() * sizeof(QGlyphJustification));
textItem.glyphs.numGlyphs = glyphCount;
textItem.glyphs.glyphs = reinterpret_cast<HB_Glyph *>(const_cast<quint32 *>(glyphArray));
const int numBytes = glyphCount * sizeof(quint32);
qint64 pos = buffer.size();
buffer.resize(pos + numBytes);
- qMemSet(buffer.data() + pos, 0xff, numBytes);
+ memset(buffer.data() + pos, 0xff, numBytes);
dev->seek(pos + numBytes);
}
const int numBytes = glyphCount * sizeof(quint32);
qint64 pos = buffer.size();
buffer.resize(pos + numBytes);
- qMemSet(buffer.data() + pos, 0xff, numBytes);
+ memset(buffer.data() + pos, 0xff, numBytes);
dev->seek(pos + numBytes);
}
return false;
}
- qMemCopy(buffer, tableData, tableSize);
+ memcpy(buffer, tableData, tableSize);
m_directWriteFontFace->ReleaseFontTable(tableContext);
return true;
int size = width * height * 3;
if (size > 0) {
BYTE *alphaValues = new BYTE[size];
- qMemSet(alphaValues, size, 0);
+ memset(alphaValues, size, 0);
hr = glyphAnalysis->CreateAlphaTexture(DWRITE_TEXTURE_CLEARTYPE_3x1,
&rect,
return d->glyphIndexes;
} else {
QVector<quint32> indexes(d->glyphIndexDataSize);
- qMemCopy(indexes.data(), d->glyphIndexData, d->glyphIndexDataSize * sizeof(quint32));
+ memcpy(indexes.data(), d->glyphIndexData, d->glyphIndexDataSize * sizeof(quint32));
return indexes;
}
}
return d->glyphPositions;
} else {
QVector<QPointF> glyphPositions(d->glyphPositionDataSize);
- qMemCopy(glyphPositions.data(), d->glyphPositionData,
+ memcpy(glyphPositions.data(), d->glyphPositionData,
d->glyphPositionDataSize * sizeof(QPointF));
return glyphPositions;
}
int numGlyphs = glyphIndexes.size();
QVarLengthGlyphLayoutArray glyphs(numGlyphs);
- qMemCopy(glyphs.glyphs, glyphIndexes.data(), numGlyphs * sizeof(quint32));
+ memcpy(glyphs.glyphs, glyphIndexes.data(), numGlyphs * sizeof(quint32));
d->fontEngine->recalcAdvances(&glyphs, 0);
kerningEnabled = this->font(si).d->kerning;
HB_ShaperItem entire_shaper_item;
- qMemSet(&entire_shaper_item, 0, sizeof(entire_shaper_item));
+ memset(&entire_shaper_item, 0, sizeof(entire_shaper_item));
entire_shaper_item.string = reinterpret_cast<const HB_UChar16 *>(layoutData->string.constData());
entire_shaper_item.stringLength = layoutData->string.length();
entire_shaper_item.item.script = (HB_Script)si.analysis.script;
if (maxAvail == 0)
return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0;
// FIXME what about "Aborted" state?
- qMemCopy(data, d->downloadBuffer + d->downloadBufferReadPosition, maxAvail);
+ memcpy(data, d->downloadBuffer + d->downloadBufferReadPosition, maxAvail);
d->downloadBufferReadPosition += maxAvail;
return maxAvail;
}
static inline void toBuffer(const QString &what, WCHAR **ptr)
{
const int length = 1 + what.size();
- qMemCopy(*ptr, what.utf16(), length * sizeof(WCHAR));
+ memcpy(*ptr, what.utf16(), length * sizeof(WCHAR));
*ptr += length;
}
return false;
}
- qMemCopy(buffer, tableData, tableSize);
+ memcpy(buffer, tableData, tableSize);
m_directWriteFontFace->ReleaseFontTable(tableContext);
return true;
int size = width * height * 3;
BYTE *alphaValues = new BYTE[size];
- qMemSet(alphaValues, size, 0);
+ memset(alphaValues, size, 0);
hr = glyphAnalysis->CreateAlphaTexture(DWRITE_TEXTURE_CLEARTYPE_3x1,
&rect,
const int padding = sym.lineNum - lineNum;
if (padding > 0) {
output.resize(output.size() + padding);
- qMemSet(output.data() + output.size() - padding, '\n', padding);
+ memset(output.data() + output.size() - padding, '\n', padding);
lineNum = sym.lineNum;
}
adjacent to which and compute the spacings correctly.
*/
QVarLengthArray<QGridBox *> grid(rr * cc);
- qMemSet(grid.data(), 0, rr * cc * sizeof(QGridBox *));
+ memset(grid.data(), 0, rr * cc * sizeof(QGridBox *));
/*
Initialize 'sizes' and 'grid' data structures, and insert
if (readSize < 0)
return -1;
- qMemCopy(data, openFile_->content.constData() + position_, readSize);
+ memcpy(data, openFile_->content.constData() + position_, readSize);
position_ += readSize;
return readSize;
void tst_QByteArray::qvsnprintf()
{
char buf[20];
- qMemSet(buf, 42, sizeof(buf));
+ memset(buf, 42, sizeof(buf));
QCOMPARE(::qsnprintf(buf, 10, "%s", "bubu"), 4);
QCOMPARE(static_cast<const char *>(buf), "bubu");
QCOMPARE(buf[5], char(42));
#endif
- qMemSet(buf, 42, sizeof(buf));
+ memset(buf, 42, sizeof(buf));
QCOMPARE(::qsnprintf(buf, 5, "%s", "bubu"), 4);
QCOMPARE(static_cast<const char *>(buf), "bubu");
QCOMPARE(buf[5], char(42));
- qMemSet(buf, 42, sizeof(buf));
+ memset(buf, 42, sizeof(buf));
#ifdef Q_OS_WIN
// VS 2005 uses the Qt implementation of vsnprintf.
# if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
QCOMPARE(buf[4], char(42));
#ifndef Q_OS_WIN
- qMemSet(buf, 42, sizeof(buf));
+ memset(buf, 42, sizeof(buf));
QCOMPARE(::qsnprintf(buf, 10, ""), 0);
#endif
}
if (paddingBytes == 0)
return;
for (int y = 0; y < image->height(); ++y) {
- qMemSet(image->scanLine(y) + effectiveBytesPerLine, 0, paddingBytes);
+ memset(image->scanLine(y) + effectiveBytesPerLine, 0, paddingBytes);
}
}
SKIP_IF_UNSUPPORTED(format);
QImage niceImage(64, 64, QImage::Format_ARGB32);
- qMemSet(niceImage.bits(), 0, niceImage.byteCount());
+ memset(niceImage.bits(), 0, niceImage.byteCount());
QImageWriter writer(fileName /* , 0 - no format! */);
if (error != 0) {
if (initial_files.at(i)[0] == '.') {
QString hiddenFile = QDir::toNativeSeparators(file.fileName());
wchar_t nativeHiddenFile[MAX_PATH];
- qMemSet(nativeHiddenFile, 0, sizeof(nativeHiddenFile));
+ memset(nativeHiddenFile, 0, sizeof(nativeHiddenFile));
hiddenFile.toWCharArray(nativeHiddenFile);
DWORD currentAttributes = ::GetFileAttributes(nativeHiddenFile);
if (currentAttributes == 0xFFFFFFFF) {
}
case QVariant::Image: {
QImage img(size, QImage::Format_Mono);
- qMemSet(img.bits(), 0, img.byteCount());
+ memset(img.bits(), 0, img.byteCount());
value = img;
break;
}
uchar *p = img.bits() + bpl - padBytes;
const int h = img.height();
for (int y = 0; y < h; ++y) {
- qMemSet(p, 0, padBytes);
+ memset(p, 0, padBytes);
p += bpl;
}
}
while (i != b)
new (--i) T;
} else {
- qMemSet(m_begin, 0, asize * sizeof(T));
+ memset(m_begin, 0, asize * sizeof(T));
}
}
} else if (asize > xsize) {
// initialize newly allocated memory to 0
- qMemSet(xbegin + xsize, 0, (asize - xsize) * sizeof(T));
+ memset(xbegin + xsize, 0, (asize - xsize) * sizeof(T));
}
xsize = asize;