diff --git a/connectivity/source/drivers/macab/MacabRecords.cxx b/connectivity/source/drivers/macab/MacabRecords.cxx index 17ee6585d45c..07d462425e65 100644 --- a/connectivity/source/drivers/macab/MacabRecords.cxx +++ b/connectivity/source/drivers/macab/MacabRecords.cxx @@ -344,7 +344,7 @@ MacabHeader *MacabRecords::createHeaderForRecordType(const CFArrayRef _records, /* While searching through the properties for required properties, these * sal_Bools will keep track of what we have found. */ - bool bFoundRequiredProperties[requiredProperties.size()]; + auto const bFoundRequiredProperties = std::make_unique(requiredProperties.size()); /* We have three MacabHeaders: headerDataForProperty is where we diff --git a/connectivity/source/drivers/macab/macabutilities.hxx b/connectivity/source/drivers/macab/macabutilities.hxx index cfe46f37f286..7e0f6b091085 100644 --- a/connectivity/source/drivers/macab/macabutilities.hxx +++ b/connectivity/source/drivers/macab/macabutilities.hxx @@ -19,6 +19,10 @@ #pragma once +#include + +#include + #include #include #include @@ -47,15 +51,15 @@ namespace connectivity::macab CFRetain(sOrig); CFIndex nStringLength = CFStringGetLength(sOrig); - UniChar unichars[nStringLength+1]; + auto const unichars = std::make_unique(nStringLength+1); //'close' the string buffer correctly unichars[nStringLength] = '\0'; - CFStringGetCharacters (sOrig, CFRangeMake(0,nStringLength), unichars); + CFStringGetCharacters (sOrig, CFRangeMake(0,nStringLength), unichars.get()); CFRelease(sOrig); - return OUString(reinterpret_cast(unichars)); + return OUString(reinterpret_cast(unichars.get())); } diff --git a/fpicker/source/aqua/NSString_OOoAdditions.mm b/fpicker/source/aqua/NSString_OOoAdditions.mm index 23ae6bc5c853..5721674f8121 100644 --- a/fpicker/source/aqua/NSString_OOoAdditions.mm +++ b/fpicker/source/aqua/NSString_OOoAdditions.mm @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include + #include "NSString_OOoAdditions.hxx" @implementation NSString (OOoAdditions) @@ -32,14 +36,14 @@ { unsigned int nFileNameLength = [self length]; - UniChar unichars[nFileNameLength+1]; + auto const unichars = std::make_unique(nFileNameLength+1); //'close' the string buffer correctly unichars[nFileNameLength] = '\0'; - [self getCharacters:unichars]; + [self getCharacters:unichars.get()]; - return OUString(reinterpret_cast(unichars)); + return OUString(reinterpret_cast(unichars.get())); } @end diff --git a/shell/source/backends/macbe/macbackend.mm b/shell/source/backends/macbe/macbackend.mm index e84ecd4b8013..7733bf95da6c 100644 --- a/shell/source/backends/macbe/macbackend.mm +++ b/shell/source/backends/macbe/macbackend.mm @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include // For MAXHOSTNAMELEN constant #include @@ -157,13 +160,13 @@ static OUString CFStringToOUString(const CFStringRef sOrig) { CFIndex nStringLen = CFStringGetLength(sOrig)+1; // Allocate a c string buffer - char sBuffer[nStringLen]; + auto const sBuffer = std::make_unique(nStringLen); - CFStringGetCString(sOrig, sBuffer, nStringLen, kCFStringEncodingASCII); + CFStringGetCString(sOrig, sBuffer.get(), nStringLen, kCFStringEncodingASCII); CFRelease(sOrig); - return OUString::createFromAscii(sBuffer); + return OUString::createFromAscii(sBuffer.get()); } static OUString GetOUString( NSString* pStr ) diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index f8608f62c2f7..4071155e28cc 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -19,6 +19,8 @@ #include +#include + #include #include #include @@ -2048,7 +2050,7 @@ static NSArray *getMergedAccessibilityChildren(NSArray *pDefaultChildren, NSArra // Skip the posting of SalEvent::ExtTextInput and // SalEvent::EndExtTextInput events for private use area characters. NSUInteger nLen = [pChars length]; - unichar pBuf[ nLen + 1 ]; + auto const pBuf = std::make_unique( nLen + 1 ); NSUInteger nBufLen = 0; for ( NSUInteger i = 0; i < nLen; i++ ) { @@ -2060,7 +2062,7 @@ static NSArray *getMergedAccessibilityChildren(NSArray *pDefaultChildren, NSArra } pBuf[nBufLen] = 0; - pNewMarkedText = [NSString stringWithCharacters:pBuf length:nBufLen]; + pNewMarkedText = [NSString stringWithCharacters:pBuf.get() length:nBufLen]; if (!pNewMarkedText || ![pNewMarkedText length]) bNeedsExtTextInput = false; } diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index f800e3c15829..0522ff8d58e7 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -18,6 +18,9 @@ */ #include + +#include + #include #include @@ -77,8 +80,8 @@ public: bool FontHasCharacter(CTFontRef pFont, const OUString& rString, sal_Int32 nIndex, sal_Int32 nLen) { - CGGlyph glyphs[nLen]; - return CTFontGetGlyphsForCharacters(pFont, reinterpret_cast(rString.getStr() + nIndex), glyphs, nLen); + auto const glyphs = std::make_unique(nLen); + return CTFontGetGlyphsForCharacters(pFont, reinterpret_cast(rString.getStr() + nIndex), glyphs.get(), nLen); } }