[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.20-204-g221d8e8

eric at webkit.org eric at webkit.org
Wed Feb 10 22:11:21 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 91d23c707dcfbe09801601ec0c1bffe5dc4e35c0
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Feb 3 21:17:22 2010 +0000

    2010-02-03  Kwang Yul Seo  <skyul at company100.net>
    
            Reviewed by Eric Seidel.
    
            [BREWMP] Implement OwnPtrBrew to make sure BREW instances are freed.
            https://bugs.webkit.org/show_bug.cgi?id=34518
    
            Add OwnPtrBrew to release IFile, IFileMgr and IBitmap instances.
    
            * wtf/brew/OwnPtrBrew.cpp: Added.
            (WTF::IFileMgr):
            (WTF::IFile):
            (WTF::IBitmap):
            (WTF::freeOwnedPtrBrew):
            * wtf/brew/OwnPtrBrew.h: Added.
            (WTF::OwnPtrBrew::OwnPtrBrew):
            (WTF::OwnPtrBrew::~OwnPtrBrew):
            (WTF::OwnPtrBrew::get):
            (WTF::OwnPtrBrew::release):
            (WTF::OwnPtrBrew::outPtr):
            (WTF::OwnPtrBrew::set):
            (WTF::OwnPtrBrew::clear):
            (WTF::OwnPtrBrew::operator*):
            (WTF::OwnPtrBrew::operator->):
            (WTF::OwnPtrBrew::operator!):
            (WTF::OwnPtrBrew::operator UnspecifiedBoolType):
            (WTF::OwnPtrBrew::swap):
            (WTF::swap):
            (WTF::operator==):
            (WTF::operator!=):
            (WTF::getPtr):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54294 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index df200ad..07386f3 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,37 @@
 2010-02-03  Kwang Yul Seo  <skyul at company100.net>
 
+        Reviewed by Eric Seidel.
+
+        [BREWMP] Implement OwnPtrBrew to make sure BREW instances are freed.
+        https://bugs.webkit.org/show_bug.cgi?id=34518
+
+        Add OwnPtrBrew to release IFile, IFileMgr and IBitmap instances.
+
+        * wtf/brew/OwnPtrBrew.cpp: Added.
+        (WTF::IFileMgr):
+        (WTF::IFile):
+        (WTF::IBitmap):
+        (WTF::freeOwnedPtrBrew):
+        * wtf/brew/OwnPtrBrew.h: Added.
+        (WTF::OwnPtrBrew::OwnPtrBrew):
+        (WTF::OwnPtrBrew::~OwnPtrBrew):
+        (WTF::OwnPtrBrew::get):
+        (WTF::OwnPtrBrew::release):
+        (WTF::OwnPtrBrew::outPtr):
+        (WTF::OwnPtrBrew::set):
+        (WTF::OwnPtrBrew::clear):
+        (WTF::OwnPtrBrew::operator*):
+        (WTF::OwnPtrBrew::operator->):
+        (WTF::OwnPtrBrew::operator!):
+        (WTF::OwnPtrBrew::operator UnspecifiedBoolType):
+        (WTF::OwnPtrBrew::swap):
+        (WTF::swap):
+        (WTF::operator==):
+        (WTF::operator!=):
+        (WTF::getPtr):
+
+2010-02-03  Kwang Yul Seo  <skyul at company100.net>
+
         Reviewed by Darin Adler.
 
         Export WTF::fastStrDup symbol
diff --git a/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp b/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp
new file mode 100644
index 0000000..dadd82e
--- /dev/null
+++ b/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 Company 100, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "OwnPtrBrew.h"
+
+#include <AEEBitmap.h>
+#include <AEEFile.h>
+#include <AEEStdLib.h>
+
+namespace WTF {
+
+template <> void freeOwnedPtrBrew<IFileMgr>(IFileMgr* ptr)
+{
+    if (ptr)
+        IFILEMGR_Release(ptr);
+}
+
+template <> void freeOwnedPtrBrew<IFile>(IFile* ptr)
+{
+    if (ptr)
+        IFILE_Release(ptr);
+}
+
+template <> void freeOwnedPtrBrew<IBitmap>(IBitmap* ptr)
+{
+    if (ptr)
+        IBitmap_Release(ptr);
+}
+
+template <typename T> void freeOwnedPtrBrew(T* ptr)
+{
+    FREEIF(ptr);
+}
+
+} // namespace WTF
diff --git a/JavaScriptCore/wtf/brew/OwnPtrBrew.h b/JavaScriptCore/wtf/brew/OwnPtrBrew.h
new file mode 100644
index 0000000..1bb44fc
--- /dev/null
+++ b/JavaScriptCore/wtf/brew/OwnPtrBrew.h
@@ -0,0 +1,133 @@
+/*
+ *  Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ *  Copyright (C) 2008 Collabora Ltd.
+ *  Copyright (C) 2010 Company 100, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef OwnPtrBrew_h
+#define OwnPtrBrew_h
+
+#include <algorithm>
+#include <wtf/Assertions.h>
+#include <wtf/Noncopyable.h>
+
+// Forward delcarations at this point avoid the need to include BREW includes
+// in WTF headers.
+typedef struct _IFileMgr IFileMgr;
+typedef struct _IFile IFile;
+typedef struct IBitmap IBitmap;
+
+namespace WTF {
+
+template <typename T> void freeOwnedPtrBrew(T* ptr);
+template<> void freeOwnedPtrBrew<IFileMgr>(IFileMgr*);
+template<> void freeOwnedPtrBrew<IFile>(IFile*);
+template<> void freeOwnedPtrBrew<IBitmap>(IBitmap*);
+
+template <typename T> class OwnPtrBrew : public Noncopyable {
+public:
+    explicit OwnPtrBrew(T* ptr = 0) : m_ptr(ptr) { }
+    ~OwnPtrBrew() { freeOwnedPtrBrew(m_ptr); }
+
+    T* get() const { return m_ptr; }
+    T* release()
+    {
+        T* ptr = m_ptr;
+        m_ptr = 0;
+        return ptr;
+    }
+
+    T*& outPtr()
+    {
+        ASSERT(!m_ptr);
+        return m_ptr;
+    }
+
+    void set(T* ptr)
+    {
+        ASSERT(!ptr || m_ptr != ptr);
+        freeOwnedPtrBrew(m_ptr);
+        m_ptr = ptr;
+    }
+
+    void clear()
+    {
+        freeOwnedPtrBrew(m_ptr);
+        m_ptr = 0;
+    }
+
+    T& operator*() const
+    {
+        ASSERT(m_ptr);
+        return *m_ptr;
+    }
+
+    T* operator->() const
+    {
+        ASSERT(m_ptr);
+        return m_ptr;
+    }
+
+    bool operator!() const { return !m_ptr; }
+
+    // This conversion operator allows implicit conversion to bool but not to other integer types.
+    typedef T* OwnPtrBrew::*UnspecifiedBoolType;
+    operator UnspecifiedBoolType() const { return m_ptr ? &OwnPtrBrew::m_ptr : 0; }
+
+    void swap(OwnPtrBrew& o) { std::swap(m_ptr, o.m_ptr); }
+
+private:
+    T* m_ptr;
+};
+
+template <typename T> inline void swap(OwnPtrBrew<T>& a, OwnPtrBrew<T>& b)
+{
+    a.swap(b);
+}
+
+template <typename T, typename U> inline bool operator==(const OwnPtrBrew<T>& a, U* b)
+{
+    return a.get() == b;
+}
+
+template <typename T, typename U> inline bool operator==(T* a, const OwnPtrBrew<U>& b)
+{
+    return a == b.get();
+}
+
+template <typename T, typename U> inline bool operator!=(const OwnPtrBrew<T>& a, U* b)
+{
+    return a.get() != b;
+}
+
+template <typename T, typename U> inline bool operator!=(T* a, const OwnPtrBrew<U>& b)
+{
+    return a != b.get();
+}
+
+template <typename T> inline typename OwnPtrBrew<T>::PtrType getPtr(const OwnPtrBrew<T>& p)
+{
+    return p.get();
+}
+
+} // namespace WTF
+
+using WTF::OwnPtrBrew;
+
+#endif // OwnPtrBrew_h

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list