diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-01-24 10:38:23 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-01-24 10:38:23 +0100 |
commit | d63b767c699e1658516c2a4514e4f0461ae29dd2 (patch) | |
tree | 1054ab623c3d33b39e66e80620c32f0005302ea3 /vcl | |
parent | f0b38738d82dbbc11e9507ee79339cb6563efaa1 (diff) |
loplugin:useuniqueptr
Change-Id: I502ebf4024cd9b0ee61d58d6b6a8e342c7ceac08
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 5c4d8347f9b3..d1aebb3e6df6 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -22,6 +22,7 @@ #include <algorithm> #include <map> +#include <memory> #include <set> #include <string.h> #include <svsys.h> @@ -74,19 +75,17 @@ class RawFontData { public: explicit RawFontData( HDC, DWORD nTableTag=0 ); - ~RawFontData() { delete[] mpRawBytes; } - const unsigned char* get() const { return mpRawBytes; } - const unsigned char* steal() { unsigned char* p = mpRawBytes; mpRawBytes = nullptr; return p; } + const unsigned char* get() const { return mpRawBytes.get(); } + const unsigned char* steal() { return mpRawBytes.release(); } int size() const { return mnByteCount; } private: - unsigned char* mpRawBytes; + std::unique_ptr<unsigned char[]> mpRawBytes; unsigned mnByteCount; }; RawFontData::RawFontData( HDC hDC, DWORD nTableTag ) -: mpRawBytes( nullptr ) -, mnByteCount( 0 ) +: mnByteCount( 0 ) { // get required size in bytes mnByteCount = ::GetFontData( hDC, nTableTag, 0, nullptr, 0 ); @@ -96,7 +95,7 @@ RawFontData::RawFontData( HDC hDC, DWORD nTableTag ) return; // allocate the array - mpRawBytes = new unsigned char[ mnByteCount ]; + mpRawBytes.reset(new unsigned char[ mnByteCount ]); // get raw data in chunks small enough for GetFontData() unsigned nRawDataOfs = 0; @@ -111,7 +110,7 @@ RawFontData::RawFontData( HDC hDC, DWORD nTableTag ) if( nFDGet > nMaxChunkSize ) nFDGet = nMaxChunkSize; const DWORD nFDGot = ::GetFontData( hDC, nTableTag, nRawDataOfs, - mpRawBytes + nRawDataOfs, nFDGet ); + mpRawBytes.get() + nRawDataOfs, nFDGet ); if( !nFDGot ) break; else if( nFDGot != GDI_ERROR ) @@ -128,8 +127,7 @@ RawFontData::RawFontData( HDC hDC, DWORD nTableTag ) // cleanup if the raw data is incomplete if( nRawDataOfs != mnByteCount ) { - delete[] mpRawBytes; - mpRawBytes = nullptr; + mpRawBytes.reset(); } } |