summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Fernengel <harald@trolltech.com>2009-06-02 15:02:00 +0200
committerHarald Fernengel <harald@trolltech.com>2009-06-02 15:02:00 +0200
commit5be3335436501c5e0d3f5cb047edba1371aeb187 (patch)
treea0c402ad460151c05c5b097f454c8dbc1eff5495 /src
parent4ae7a683217eb2a7e9fc2fe2ed173e7da277038b (diff)
Use a QVarLengthArray instead of some hacky self-made container
This won't leak on error case, and will work with arbitrary sizes. Also changed from int to short as instructed by Samuel. Reviewed-by: Samuel <qt-info@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 847904bc30..58ffb02718 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -3876,11 +3876,7 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r
{
Q_ASSERT(c1->clipSpanHeight == c2->clipSpanHeight && c1->clipSpanHeight == result->clipSpanHeight);
- // ### buffer overflow possible
- const int BUFFER_SIZE = 4096;
- int buffer[BUFFER_SIZE];
- int *b = buffer;
- int bsize = BUFFER_SIZE;
+ QVarLengthArray<short, 4096> buffer;
QClipData::ClipLine *c1ClipLines = const_cast<QClipData *>(c1)->clipLines();
QClipData::ClipLine *c2ClipLines = const_cast<QClipData *>(c2)->clipLines();
@@ -3907,11 +3903,8 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r
// find required length
int max = qMax(c1_spans[c1_count - 1].x + c1_spans[c1_count - 1].len,
c2_spans[c2_count - 1].x + c2_spans[c2_count - 1].len);
- if (max > bsize) {
- b = (int *)realloc(bsize == BUFFER_SIZE ? 0 : b, max*sizeof(int));
- bsize = max;
- }
- memset(buffer, 0, BUFFER_SIZE * sizeof(int));
+ buffer.resize(max);
+ memset(buffer.data(), 0, buffer.size() * sizeof(short));
// Fill with old spans.
for (int i = 0; i < c1_count; ++i) {
@@ -3947,8 +3940,6 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r
result->appendSpan(sx, x - sx, y, coverage);
}
}
- if (b != buffer)
- free(b);
}
void QRasterPaintEnginePrivate::initializeRasterizer(QSpanData *data)