Remove unused PossiblyNull
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Feb 2015 06:02:30 +0000 (06:02 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Feb 2015 06:02:30 +0000 (06:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142124

Reviewed by Andreas Kling.

* WTF.vcxproj/WTF.vcxproj: Removed the file.
* WTF.vcxproj/WTF.vcxproj.filters: Ditto.
* WTF.xcodeproj/project.pbxproj: Ditto.
* wtf/CMakeLists.txt: Ditto.
* wtf/PossiblyNull.h: Removed.

* wtf/FastMalloc.h: Moved everything to the left.
Moved member functions out of the TryMallocReturnValue class definition.
(WTF::TryMallocReturnValue::operator PossiblyNull<T>): Deleted.
(WTF::TryMallocReturnValue::getValue): Marked inline, changed to work
only with pointer types, not arbitrary non-pointer types.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180814 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/WTF.vcxproj/WTF.vcxproj
Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/FastMalloc.h
Source/WTF/wtf/PossiblyNull.h [deleted file]

index 3caf43fc5c96e2caf221edcd18f0387fe7f0173f..249f08e1ea15c154900f74c61fcf4126894bf0f0 100644 (file)
@@ -1,3 +1,22 @@
+2015-02-27  Darin Adler  <darin@apple.com>
+
+        Remove unused PossiblyNull
+        https://bugs.webkit.org/show_bug.cgi?id=142124
+
+        Reviewed by Andreas Kling.
+
+        * WTF.vcxproj/WTF.vcxproj: Removed the file.
+        * WTF.vcxproj/WTF.vcxproj.filters: Ditto.
+        * WTF.xcodeproj/project.pbxproj: Ditto.
+        * wtf/CMakeLists.txt: Ditto.
+        * wtf/PossiblyNull.h: Removed.
+
+        * wtf/FastMalloc.h: Moved everything to the left.
+        Moved member functions out of the TryMallocReturnValue class definition.
+        (WTF::TryMallocReturnValue::operator PossiblyNull<T>): Deleted.
+        (WTF::TryMallocReturnValue::getValue): Marked inline, changed to work
+        only with pointer types, not arbitrary non-pointer types.
+
 2015-02-26  Brent Fulgham  <bfulgham@apple.com>
 
         [Win] Make build logs more legible by reducing noise
index 465866d6ec55602c8a1bfcbd8d1d7b0a581511a1..bc9b8c1f8e6c970659d0b024153ac17e9f0bceca 100644 (file)
     <ClInclude Include="..\wtf\PassRef.h" />
     <ClInclude Include="..\wtf\PassRefPtr.h" />
     <ClInclude Include="..\wtf\Platform.h" />
-    <ClInclude Include="..\wtf\PossiblyNull.h" />
     <ClInclude Include="..\wtf\PrintStream.h" />
     <ClInclude Include="..\wtf\RAMSize.h" />
     <ClInclude Include="..\wtf\RandomNumber.h" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index 764e0d1192b3424dc62e52dc3ceff8851cfe81ec..d307de6da19d2711a12c3ac256e31c2ffb4b16b6 100644 (file)
     <ClInclude Include="..\wtf\Platform.h">
       <Filter>wtf</Filter>
     </ClInclude>
-    <ClInclude Include="..\wtf\PossiblyNull.h">
-      <Filter>wtf</Filter>
-    </ClInclude>
     <ClInclude Include="..\wtf\PrintStream.h">
       <Filter>wtf</Filter>
     </ClInclude>
     <None Include="WTFPostBuild.cmd" />
     <None Include="WTFPreBuild.cmd" />
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index 15d2bd4192c876fa6a76e5c4445c0b0b236788ab..be50b87638cf9a1ee2e066f984f77b3a06b12ffe 100644 (file)
                A8A47408151A825B004123FF /* ParallelJobsLibdispatch.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472E9151A825B004123FF /* ParallelJobsLibdispatch.h */; };
                A8A4740B151A825B004123FF /* PassOwnPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472EC151A825B004123FF /* PassOwnPtr.h */; };
                A8A4740C151A825B004123FF /* PassRefPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472ED151A825B004123FF /* PassRefPtr.h */; };
-               A8A4740F151A825B004123FF /* PossiblyNull.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472F3151A825B004123FF /* PossiblyNull.h */; };
                A8A47414151A825B004123FF /* RandomNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472FB151A825B004123FF /* RandomNumber.cpp */; };
                A8A47415151A825B004123FF /* RandomNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472FC151A825B004123FF /* RandomNumber.h */; };
                A8A47416151A825B004123FF /* RandomNumberSeed.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472FD151A825B004123FF /* RandomNumberSeed.h */; };
                A8A472E9151A825B004123FF /* ParallelJobsLibdispatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParallelJobsLibdispatch.h; sourceTree = "<group>"; };
                A8A472EC151A825B004123FF /* PassOwnPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PassOwnPtr.h; sourceTree = "<group>"; };
                A8A472ED151A825B004123FF /* PassRefPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PassRefPtr.h; sourceTree = "<group>"; };
-               A8A472F3151A825B004123FF /* PossiblyNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PossiblyNull.h; sourceTree = "<group>"; };
                A8A472FB151A825B004123FF /* RandomNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RandomNumber.cpp; sourceTree = "<group>"; };
                A8A472FC151A825B004123FF /* RandomNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomNumber.h; sourceTree = "<group>"; };
                A8A472FD151A825B004123FF /* RandomNumberSeed.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomNumberSeed.h; sourceTree = "<group>"; };
                                93B1AA7F180E5AF3004A2F05 /* PassRef.h */,
                                A8A472ED151A825B004123FF /* PassRefPtr.h */,
                                A876DBD7151816E500DADB95 /* Platform.h */,
-                               A8A472F3151A825B004123FF /* PossiblyNull.h */,
                                0F9D335D165DBA73005AD387 /* PrintStream.cpp */,
                                0F9D335E165DBA73005AD387 /* PrintStream.h */,
                                0FC4488216FE9FE100844BE9 /* ProcessID.h */,
                                A8A4740B151A825B004123FF /* PassOwnPtr.h in Headers */,
                                A8A4740C151A825B004123FF /* PassRefPtr.h in Headers */,
                                A876DBD8151816E500DADB95 /* Platform.h in Headers */,
-                               A8A4740F151A825B004123FF /* PossiblyNull.h in Headers */,
                                0FB14E19180FA218009B6B4D /* Bag.h in Headers */,
                                0F9D3363165DBA73005AD387 /* PrintStream.h in Headers */,
                                0FC4488316FE9FE100844BE9 /* ProcessID.h in Headers */,
index d2bbc7a33335c95a4d81c9f4d33e20f93b12f4ca..682b8d4c3c4ac8a97eaf6ef1fa63a2e6f00408ed 100644 (file)
@@ -71,7 +71,6 @@ set(WTF_HEADERS
     PassRef.h
     PassRefPtr.h
     Platform.h
-    PossiblyNull.h
     PrintStream.h
     ProcessID.h
     RAMSize.h
index f7612e0e6ea445247b40d69f44a19dbfafbf1abc..d099245faf8072caac182d740c9e40ef7420292b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ *  Copyright (C) 2005-2009, 2015 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Library General Public
 
 #include <new>
 #include <stdlib.h>
-#include <wtf/PossiblyNull.h>
 #include <wtf/StdLibExtras.h>
 
 namespace WTF {
 
-    // These functions call CRASH() if an allocation fails.
-    WTF_EXPORT_PRIVATE void* fastMalloc(size_t);
-    WTF_EXPORT_PRIVATE void* fastZeroedMalloc(size_t);
-    WTF_EXPORT_PRIVATE void* fastCalloc(size_t numElements, size_t elementSize);
-    WTF_EXPORT_PRIVATE void* fastRealloc(void*, size_t);
-    WTF_EXPORT_PRIVATE char* fastStrDup(const char*);
-    WTF_EXPORT_PRIVATE size_t fastMallocSize(const void*);
-    WTF_EXPORT_PRIVATE size_t fastMallocGoodSize(size_t);
-
-    // Allocations from fastAlignedMalloc() must be freed using fastAlignedFree().
-    WTF_EXPORT_PRIVATE void* fastAlignedMalloc(size_t alignment, size_t);
-    WTF_EXPORT_PRIVATE void fastAlignedFree(void*);
-
-    struct TryMallocReturnValue {
-        TryMallocReturnValue(void* data)
-            : m_data(data)
-        {
-        }
-        TryMallocReturnValue(const TryMallocReturnValue& source)
-            : m_data(source.m_data)
-        {
-            source.m_data = 0;
-        }
-        ~TryMallocReturnValue() { ASSERT(!m_data); }
-        template <typename T> bool getValue(T& data) WARN_UNUSED_RETURN;
-        template <typename T> operator PossiblyNull<T>()
-        { 
-            T value; 
-            getValue(value); 
-            return PossiblyNull<T>(value);
-        } 
-    private:
-        mutable void* m_data;
-    };
-    
-    template <typename T> bool TryMallocReturnValue::getValue(T& data)
-    {
-        union u { void* data; T target; } res;
-        res.data = m_data;
-        data = res.target;
-        bool returnValue = !!m_data;
-        m_data = 0;
-        return returnValue;
-    }
-
-    WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastMalloc(size_t n);
-    TryMallocReturnValue tryFastZeroedMalloc(size_t n);
-    WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastCalloc(size_t n_elements, size_t element_size);
-    WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastRealloc(void* p, size_t n);
-
-    WTF_EXPORT_PRIVATE void fastFree(void*);
-
-    WTF_EXPORT_PRIVATE void releaseFastMallocFreeMemory();
-    WTF_EXPORT_PRIVATE void releaseFastMallocFreeMemoryForThisThread();
-    
-    struct FastMallocStatistics {
-        size_t reservedVMBytes;
-        size_t committedVMBytes;
-        size_t freeListBytes;
-    };
-    WTF_EXPORT_PRIVATE FastMallocStatistics fastMallocStatistics();
-
-    // This defines a type which holds an unsigned integer and is the same
-    // size as the minimally aligned memory allocation.
-    typedef unsigned long long AllocAlignmentInteger;
+class TryMallocReturnValue {
+public:
+    TryMallocReturnValue(void*);
+    TryMallocReturnValue(TryMallocReturnValue&&);
+    ~TryMallocReturnValue();
+    template<typename T> bool getValue(T*&) WARN_UNUSED_RETURN;
+private:
+    void operator=(TryMallocReturnValue&&) = delete;
+    mutable void* m_data;
+};
+
+// These functions call CRASH() if an allocation fails.
+WTF_EXPORT_PRIVATE void* fastMalloc(size_t);
+WTF_EXPORT_PRIVATE void* fastZeroedMalloc(size_t);
+WTF_EXPORT_PRIVATE void* fastCalloc(size_t numElements, size_t elementSize);
+WTF_EXPORT_PRIVATE void* fastRealloc(void*, size_t);
+WTF_EXPORT_PRIVATE char* fastStrDup(const char*);
+
+WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastMalloc(size_t);
+TryMallocReturnValue tryFastZeroedMalloc(size_t);
+WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastCalloc(size_t numElements, size_t elementSize);
+WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastRealloc(void*, size_t);
+
+WTF_EXPORT_PRIVATE void fastFree(void*);
+
+// Allocations from fastAlignedMalloc() must be freed using fastAlignedFree().
+WTF_EXPORT_PRIVATE void* fastAlignedMalloc(size_t alignment, size_t);
+WTF_EXPORT_PRIVATE void fastAlignedFree(void*);
+
+WTF_EXPORT_PRIVATE size_t fastMallocSize(const void*);
+WTF_EXPORT_PRIVATE size_t fastMallocGoodSize(size_t);
+
+WTF_EXPORT_PRIVATE void releaseFastMallocFreeMemory();
+WTF_EXPORT_PRIVATE void releaseFastMallocFreeMemoryForThisThread();
+
+struct FastMallocStatistics {
+    size_t reservedVMBytes;
+    size_t committedVMBytes;
+    size_t freeListBytes;
+};
+WTF_EXPORT_PRIVATE FastMallocStatistics fastMallocStatistics();
+
+// This defines a type which holds an unsigned integer and is the same
+// size as the minimally aligned memory allocation.
+typedef unsigned long long AllocAlignmentInteger;
+
+inline TryMallocReturnValue::TryMallocReturnValue(void* data)
+    : m_data(data)
+{
+}
+
+inline TryMallocReturnValue::TryMallocReturnValue(TryMallocReturnValue&& source)
+    : m_data(source.m_data)
+{
+    source.m_data = nullptr;
+}
+
+inline TryMallocReturnValue::~TryMallocReturnValue()
+{
+    ASSERT(!m_data);
+}
+
+template<typename T> inline bool TryMallocReturnValue::getValue(T*& data)
+{
+    data = static_cast<T*>(m_data);
+    m_data = nullptr;
+    return data;
+}
 
 } // namespace WTF
 
diff --git a/Source/WTF/wtf/PossiblyNull.h b/Source/WTF/wtf/PossiblyNull.h
deleted file mode 100644 (file)
index 46a7d71..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PossiblyNull_h
-#define PossiblyNull_h
-
-#include <wtf/Assertions.h>
-
-namespace WTF {
-
-template <typename T> struct PossiblyNull {
-    PossiblyNull(T data)
-        : m_data(data)
-    {
-    }
-    PossiblyNull(const PossiblyNull<T>& source)
-        : m_data(source.m_data)
-    {
-        source.m_data = 0;
-    }
-    ~PossiblyNull() { ASSERT(!m_data); }
-    bool getValue(T& out) WARN_UNUSED_RETURN;
-private:
-    mutable T m_data;
-};
-
-template <typename T> bool PossiblyNull<T>::getValue(T& out)
-{
-    out = m_data;
-    bool result = !!m_data;
-    m_data = 0;
-    return result;
-}
-
-}
-
-#endif