Commit f635e882 authored by Kai Koehne's avatar Kai Koehne

WinUtils: Use scoped array pointer

Requested by Friedemann
parent 2c4ae8c1
...@@ -158,10 +158,9 @@ QTCREATOR_UTILS_EXPORT QString getShortPathName(const QString &name, QString *er ...@@ -158,10 +158,9 @@ QTCREATOR_UTILS_EXPORT QString getShortPathName(const QString &name, QString *er
const DWORD length = (*getShortPathNameW)(nameC, NULL, 0); const DWORD length = (*getShortPathNameW)(nameC, NULL, 0);
if (length == 0) if (length == 0)
return name; return name;
TCHAR *buffer = new TCHAR[length]; QScopedArrayPointer<TCHAR> buffer(new TCHAR[length]);
(*getShortPathNameW)(nameC, buffer, length); (*getShortPathNameW)(nameC, buffer.data(), length);
const QString rc = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer), length); const QString rc = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer.data()), length);
delete [] buffer;
return rc; return rc;
} }
...@@ -191,10 +190,9 @@ QTCREATOR_UTILS_EXPORT QString getLongPathName(const QString &name, QString *err ...@@ -191,10 +190,9 @@ QTCREATOR_UTILS_EXPORT QString getLongPathName(const QString &name, QString *err
const DWORD length = (*getLongPathNameW)(nameC, NULL, 0); const DWORD length = (*getLongPathNameW)(nameC, NULL, 0);
if (length == 0) if (length == 0)
return name; return name;
TCHAR *buffer = new TCHAR[length]; QScopedArrayPointer<TCHAR> buffer(new TCHAR[length]);
(*getLongPathNameW)(nameC, buffer, length); (*getLongPathNameW)(nameC, buffer.data(), length);
const QString rc = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer), length); const QString rc = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer.data()), length);
delete [] buffer;
return rc; return rc;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment