Skip to content
  • paroga@webkit.org's avatar
    [WIN] Use BString in favour of BSTR to improve memory management · a4dc56a8
    paroga@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=93128
    
    Reviewed by Anders Carlsson.
    
    BString automatically calls SysFreeString() in its destructor which helps
    avoiding memory leaks. So it should be used instead of BSTR directly.
    Add operator& to BString to allow its usage for out parameters too (like COMPtr).
    This fixes already a few memory leaks in the existing code.
    
    Source/WebCore:
    
    * platform/win/BString.cpp:
    (WebCore::BString::~BString):
    (WebCore::BString::adoptBSTR):
    (WebCore::BString::clear):
    (WebCore):
    * platform/win/BString.h:
    (BString):
    (WebCore::BString::operator&):
    
    Source/WebKit/win:
    
    * DefaultPolicyDelegate.cpp:
    (DefaultPolicyDelegate::decidePolicyForNavigationAction):
    (DefaultPolicyDelegate::decidePolicyForMIMEType):
    (DefaultPolicyDelegate::unableToImplementPolicyWithError):
    * MarshallingHelpers.cpp:
    (MarshallingHelpers::KURLToBSTR):
    (MarshallingHelpers::CFStringRefToBSTR):
    (MarshallingHelpers::stringArrayToSafeArray):
    (MarshallingHelpers::safeArrayToStringArray):
    * WebCoreSupport/WebChromeClient.cpp:
    (WebChromeClient::runJavaScriptPrompt):
    * WebCoreSupport/WebEditorClient.cpp:
    (WebEditorClient::checkGrammarOfString):
    (WebEditorClient::getGuessesForWord):
    * WebFrame.cpp:
    (WebFrame::canProvideDocumentSource):
    * WebHistory.cpp:
    (WebHistory::removeItem):
    (WebHistory::addItem):
    * WebIconDatabase.cpp:
    (WebIconDatabase::startUpIconDatabase):
    * WebNotificationCenter.cpp:
    (WebNotificationCenter::postNotification):
    * WebPreferences.cpp:
    (WebPreferences::setStringValue):
    * WebView.cpp:
    (toAtomicString):
    (toString):
    (toKURL):
    (PreferencesChangedOrRemovedObserver::onNotify):
    (WebView::close):
    (WebView::canShowMIMEType):
    (WebView::initWithFrame):
    (WebView::setApplicationNameForUserAgent):
    (WebView::setCustomUserAgent):
    (WebView::userAgentForURL):
    (WebView::setCustomTextEncodingName):
    (WebView::customTextEncodingName):
    (WebView::setPreferences):
    (WebView::searchFor):
    (WebView::executeCoreCommandByName):
    (WebView::markAllMatchesForText):
    (WebView::setGroupName):
    (WebView::registerURLSchemeAsLocal):
    (WebView::replaceSelectionWithText):
    (WebView::onNotify):
    (WebView::notifyPreferencesChanged):
    (WebView::MIMETypeForExtension):
    (WebView::standardUserAgentWithApplicationName):
    (WebView::addAdditionalPluginDirectory):
    (WebView::registerEmbeddedViewMIMEType):
    (WebView::addOriginAccessWhitelistEntry):
    (WebView::removeOriginAccessWhitelistEntry):
    (WebView::geolocationDidFailWithError):
    (WebView::setDomainRelaxationForbiddenForURLScheme):
    (WebView::setCompositionForTesting):
    (WebView::confirmCompositionForTesting):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@128988 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    a4dc56a8