aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/winutils.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2011-01-05 15:31:53 +0100
committerKai Koehne <kai.koehne@nokia.com>2011-01-05 15:31:53 +0100
commitf635e8823a5f6260b4f32d9d07a7467d2027389a (patch)
tree7a19487a94d65eb4196ba2cb56670eccdf7205c8 /src/libs/utils/winutils.cpp
parent2c4ae8c1b855021cdf92b8f3604a30ce07899b5b (diff)
WinUtils: Use scoped array pointer
Requested by Friedemann
Diffstat (limited to 'src/libs/utils/winutils.cpp')
-rw-r--r--src/libs/utils/winutils.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/libs/utils/winutils.cpp b/src/libs/utils/winutils.cpp
index 098ea63fd54..6d31dde402b 100644
--- a/src/libs/utils/winutils.cpp
+++ b/src/libs/utils/winutils.cpp
@@ -158,10 +158,9 @@ QTCREATOR_UTILS_EXPORT QString getShortPathName(const QString &name, QString *er
const DWORD length = (*getShortPathNameW)(nameC, NULL, 0);
if (length == 0)
return name;
- TCHAR *buffer = new TCHAR[length];
- (*getShortPathNameW)(nameC, buffer, length);
- const QString rc = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer), length);
- delete [] buffer;
+ QScopedArrayPointer<TCHAR> buffer(new TCHAR[length]);
+ (*getShortPathNameW)(nameC, buffer.data(), length);
+ const QString rc = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer.data()), length);
return rc;
}
@@ -191,10 +190,9 @@ QTCREATOR_UTILS_EXPORT QString getLongPathName(const QString &name, QString *err
const DWORD length = (*getLongPathNameW)(nameC, NULL, 0);
if (length == 0)
return name;
- TCHAR *buffer = new TCHAR[length];
- (*getLongPathNameW)(nameC, buffer, length);
- const QString rc = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer), length);
- delete [] buffer;
+ QScopedArrayPointer<TCHAR> buffer(new TCHAR[length]);
+ (*getLongPathNameW)(nameC, buffer.data(), length);
+ const QString rc = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer.data()), length);
return rc;
}