From f65a4c931b0b849c6118a872948e9eb74dc4e011 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 16 Mar 2015 14:08:31 +0100 Subject: Replace malloc'ed tables with QVarLengthArray Basic cleanup using proper Qt classes instead of malloc. Change-Id: I532b47aac7cfe15a5963371224288bec08135f25 Reviewed-by: Thiago Macieira --- src/plugins/imageformats/tiff/qtiffhandler.cpp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index 675e6c3..9697f45 100644 --- a/src/plugins/imageformats/tiff/qtiffhandler.cpp +++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp @@ -494,20 +494,13 @@ bool QTiffHandler::write(const QImage &image) } //// write the color table // allocate the color tables - uint16 *redTable = static_cast(malloc(256 * sizeof(uint16))); - uint16 *greenTable = static_cast(malloc(256 * sizeof(uint16))); - uint16 *blueTable = static_cast(malloc(256 * sizeof(uint16))); - if (!redTable || !greenTable || !blueTable) { - free(redTable); - free(greenTable); - free(blueTable); - TIFFClose(tiff); - return false; - } - - // set the color table const int tableSize = colorTable.size(); Q_ASSERT(tableSize <= 256); + QVarLengthArray redTable(tableSize); + QVarLengthArray greenTable(tableSize); + QVarLengthArray blueTable(tableSize); + + // set the color table for (int i = 0; i