Changeset 155242 in webkit
- Timestamp:
- Sep 6, 2013 10:36:45 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r155232 r155242 1 2013-09-06 Anders Carlsson <andersca@apple.com> 2 3 Add a new smart pointer type for fastMalloc'ed memory 4 https://bugs.webkit.org/show_bug.cgi?id=120911 5 6 Reviewed by Andreas Kling. 7 8 Due to an oversight on my part, Vector::releaseBuffer() currently returns an OwnPtr 9 which means that its data will be freed with operator delete instead of fastFree. 10 11 Fix this by introducing a new MllocPtr smart pointer class and change Vector::releaseBuffer() to return it instead. 12 13 * WTF.pro: 14 * WTF.vcxproj/WTF.vcxproj: 15 * WTF.vcxproj/WTF.vcxproj.filters: 16 * WTF.xcodeproj/project.pbxproj: 17 * wtf/CMakeLists.txt: 18 * wtf/FastAllocBase.h: 19 * wtf/MallocPtr.h: Added. 20 * wtf/Vector.h: 21 * wtf/text/StringBuffer.h: 22 * wtf/text/StringImpl.h: 23 1 24 2013-09-06 Andreas Kling <akling@apple.com> 2 25 -
trunk/Source/WTF/WTF.pro
r154962 r155242 80 80 Locker.h \ 81 81 MainThread.h \ 82 MallocPtr.h \ 82 83 MathExtras.h \ 83 84 MD5.h \ -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj
r154498 r155242 185 185 <ClInclude Include="..\wtf\Locker.h" /> 186 186 <ClInclude Include="..\wtf\MainThread.h" /> 187 <ClInclude Include="..\wtf\MallocPtr.h" /> 187 188 <ClInclude Include="..\wtf\MathExtras.h" /> 188 189 <ClInclude Include="..\wtf\MD5.h" /> -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
r154962 r155242 474 474 <Filter>wtf</Filter> 475 475 </ClInclude> 476 <ClInclude Include="..\wtf\MallocPtr.h"> 477 <Filter>wtf</Filter> 478 </ClInclude> 476 479 <ClInclude Include="..\wtf\MathExtras.h"> 477 480 <Filter>wtf</Filter> -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r155171 r155242 51 51 1A1D8B9C173186CE00141DA4 /* FunctionDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A1D8B9B173186CE00141DA4 /* FunctionDispatcher.h */; }; 52 52 1A1D8B9E1731879800141DA4 /* FunctionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D8B9D1731879800141DA4 /* FunctionDispatcher.cpp */; }; 53 1A233C7D17DAA6E300A93ACF /* MallocPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A233C7C17DAA6E300A93ACF /* MallocPtr.h */; }; 53 54 1A6BB769162F300500DD16DB /* StreamBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6BB768162F300500DD16DB /* StreamBuffer.h */; }; 54 55 1FA47C8A152502DA00568D1B /* WebCoreThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FA47C88152502DA00568D1B /* WebCoreThread.cpp */; }; … … 316 317 1A1D8B9B173186CE00141DA4 /* FunctionDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionDispatcher.h; sourceTree = "<group>"; }; 317 318 1A1D8B9D1731879800141DA4 /* FunctionDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionDispatcher.cpp; sourceTree = "<group>"; }; 319 1A233C7C17DAA6E300A93ACF /* MallocPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MallocPtr.h; sourceTree = "<group>"; }; 318 320 1A3F6BE6174ADA2100B2EEA7 /* NeverDestroyed.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NeverDestroyed.h; sourceTree = "<group>"; }; 319 321 1A6BB768162F300500DD16DB /* StreamBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamBuffer.h; sourceTree = "<group>"; }; … … 697 699 A736B3581799E11A00C6F05E /* LLVMHeaders.h */, 698 700 A8A472C3151A825A004123FF /* Locker.h */, 701 A8A472CA151A825B004123FF /* MD5.cpp */, 702 A8A472CB151A825B004123FF /* MD5.h */, 699 703 A8A472C6151A825A004123FF /* MainThread.cpp */, 700 704 A8A472C7151A825B004123FF /* MainThread.h */, 705 1A233C7C17DAA6E300A93ACF /* MallocPtr.h */, 701 706 A8A472C9151A825B004123FF /* MathExtras.h */, 702 A8A472CA151A825B004123FF /* MD5.cpp */,703 A8A472CB151A825B004123FF /* MD5.h */,704 707 CD5497AA15857D0300B5BC30 /* MediaTime.cpp */, 705 708 CD5497AB15857D0300B5BC30 /* MediaTime.h */, … … 997 1000 A8A473D5151A825B004123FF /* HashIterators.h in Headers */, 998 1001 A8A473D6151A825B004123FF /* HashMap.h in Headers */, 1002 1A233C7D17DAA6E300A93ACF /* MallocPtr.h in Headers */, 999 1003 A8A473D7151A825B004123FF /* HashSet.h in Headers */, 1000 1004 A8A473D9151A825B004123FF /* HashTable.h in Headers */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r154962 r155242 49 49 MD5.h 50 50 MainThread.h 51 MallocPtr.h 51 52 MathExtras.h 52 53 MediaTime.h -
trunk/Source/WTF/wtf/Vector.h
r155152 r155242 25 25 #include <wtf/CheckedArithmetic.h> 26 26 #include <wtf/FastAllocBase.h> 27 #include <wtf/MallocPtr.h> 27 28 #include <wtf/Noncopyable.h> 28 29 #include <wtf/NotFound.h> … … 309 310 size_t capacity() const { return m_capacity; } 310 311 311 OwnPtr<T> releaseBuffer()312 MallocPtr<T> releaseBuffer() 312 313 { 313 314 T* buffer = m_buffer; 314 315 m_buffer = 0; 315 316 m_capacity = 0; 316 return adopt Ptr(buffer);317 return adoptMallocPtr(buffer); 317 318 } 318 319 … … 489 490 using Base::capacity; 490 491 491 OwnPtr<T> releaseBuffer()492 MallocPtr<T> releaseBuffer() 492 493 { 493 494 if (buffer() == inlineBuffer()) … … 667 668 template<typename Iterator> void appendRange(Iterator start, Iterator end); 668 669 669 OwnPtr<T> releaseBuffer();670 MallocPtr<T> releaseBuffer(); 670 671 671 672 void swap(Vector<T, inlineCapacity, OverflowHandler>& other) … … 1154 1155 1155 1156 template<typename T, size_t inlineCapacity, typename OverflowHandler> 1156 inline OwnPtr<T> Vector<T, inlineCapacity, OverflowHandler>::releaseBuffer()1157 { 1158 OwnPtr<T>buffer = Base::releaseBuffer();1157 inline MallocPtr<T> Vector<T, inlineCapacity, OverflowHandler>::releaseBuffer() 1158 { 1159 auto buffer = Base::releaseBuffer(); 1159 1160 if (inlineCapacity && !buffer && m_size) { 1160 1161 // If the vector had some data, but no buffer to release, … … 1162 1163 // we create a brand new buffer so the caller always gets one. 1163 1164 size_t bytes = m_size * sizeof(T); 1164 buffer = adopt Ptr(static_cast<T*>(fastMalloc(bytes)));1165 buffer = adoptMallocPtr(static_cast<T*>(fastMalloc(bytes))); 1165 1166 memcpy(buffer.get(), data(), bytes); 1166 1167 } 1167 1168 m_size = 0; 1168 return buffer .release();1169 return buffer; 1169 1170 } 1170 1171 -
trunk/Source/WTF/wtf/text/StringBuffer.h
r155126 r155242 74 74 CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < m_length); return m_data[i]; } 75 75 76 PassOwnPtr<CharType> release()76 MallocPtr<CharType> release() 77 77 { 78 78 CharType* data = m_data; 79 79 m_data = 0; 80 return adopt Ptr(data);80 return adoptMallocPtr(data); 81 81 } 82 82 -
trunk/Source/WTF/wtf/text/StringImpl.h
r155121 r155242 29 29 #include <wtf/Forward.h> 30 30 #include <wtf/MathExtras.h> 31 #include <wtf/PassOwnPtr.h>32 31 #include <wtf/StdLibExtras.h> 33 32 #include <wtf/StringHasher.h> … … 234 233 235 234 // Create a StringImpl adopting ownership of the provided buffer (BufferOwned) 236 StringImpl( PassOwnPtr<LChar> characters, unsigned length)235 StringImpl(MallocPtr<LChar> characters, unsigned length) 237 236 : m_refCount(s_refCountIncrement) 238 237 , m_length(length) … … 275 274 276 275 // Create a StringImpl adopting ownership of the provided buffer (BufferOwned) 277 StringImpl( PassOwnPtr<UChar> characters, unsigned length)276 StringImpl(MallocPtr<UChar> characters, unsigned length) 278 277 : m_refCount(s_refCountIncrement) 279 278 , m_length(length) … … 474 473 if (size > std::numeric_limits<unsigned>::max()) 475 474 CRASH(); 476 return adoptRef(new StringImpl(vector.releaseBuffer() .release(), size));475 return adoptRef(new StringImpl(vector.releaseBuffer(), size)); 477 476 } 478 477 return empty(); -
trunk/Source/WebCore/ChangeLog
r155240 r155242 1 2013-09-06 Anders Carlsson <andersca@apple.com> 2 3 Add a new smart pointer type for fastMalloc'ed memory 4 https://bugs.webkit.org/show_bug.cgi?id=120911 5 6 Reviewed by Andreas Kling. 7 8 Update for WTF changes. 9 10 * platform/network/cf/FormDataStreamCFNet.cpp: 11 (WebCore::advanceCurrentStream): 12 1 13 2013-09-06 Dirk Schulze <krit@webkit.org> 2 14 -
trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp
r155121 r155242 108 108 long long currentStreamRangeLength; 109 109 #endif 110 OwnPtr<char> currentData;110 MallocPtr<char> currentData; 111 111 CFReadStreamRef formStream; 112 112 unsigned long long streamLength; … … 142 142 if (nextInput.m_type == FormDataElement::data) { 143 143 size_t size = nextInput.m_data.size(); 144 OwnPtr<char> data = nextInput.m_data.releaseBuffer();144 MallocPtr<char> data = nextInput.m_data.releaseBuffer(); 145 145 form->currentStream = CFReadStreamCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data.get()), size, kCFAllocatorNull); 146 form->currentData = data.release();146 form->currentData = std::move(data); 147 147 } else { 148 148 #if ENABLE(BLOB)
Note: See TracChangeset
for help on using the changeset viewer.