[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
barraclough at apple.com
barraclough at apple.com
Wed Jan 20 22:28:06 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 10d6cc00872a75d347dd7418d21c694bb44fb8e3
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Jan 18 19:44:50 2010 +0000
Eeeep! reverting r53416 & r53417, more to be done to fix windows.
Reviewed by NOBODY (build fix).
* WebCore.base.exp:
* platform/sql/SQLiteFileSystem.cpp:
(WebCore::SQLiteFileSystem::openDatabase):
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::prepare):
* platform/sql/SQLiteStatement.h:
* platform/sql/chromium/SQLiteFileSystemChromium.cpp:
(WebCore::SQLiteFileSystem::openDatabase):
* platform/text/PlatformString.h:
* platform/text/String.cpp:
(WebCore::String::charactersWithNullTermination):
* platform/text/StringImpl.cpp:
(WebCore::StringImpl::operator new):
(WebCore::StringImpl::operator delete):
(WebCore::StringImpl::StringImpl):
(WebCore::StringImpl::~StringImpl):
(WebCore::StringImpl::create):
(WebCore::StringImpl::createWithTerminatingNullCharacter):
(WebCore::StringImpl::crossThreadString):
(WebCore::StringImpl::sharedBuffer):
* platform/text/StringImpl.h:
(WebCore::StringImpl::hasTerminatingNullCharacter):
(WebCore::StringImpl::inTable):
(WebCore::StringImpl::setInTable):
(WebCore::StringImpl::):
* platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::createGlobalData):
* storage/OriginUsageRecord.cpp:
(WebCore::OriginUsageRecord::addDatabase):
(WebCore::OriginUsageRecord::markDatabase):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53418 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 764fcb7..94e2912 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,5 +1,42 @@
2010-01-18 Gavin Barraclough <barraclough at apple.com>
+ Reviewed by NOBODY (build fix).
+
+ Eeeep! reverting r53416 & r53417, more to be done to fix windows.
+
+ * WebCore.base.exp:
+ * platform/sql/SQLiteFileSystem.cpp:
+ (WebCore::SQLiteFileSystem::openDatabase):
+ * platform/sql/SQLiteStatement.cpp:
+ (WebCore::SQLiteStatement::prepare):
+ * platform/sql/SQLiteStatement.h:
+ * platform/sql/chromium/SQLiteFileSystemChromium.cpp:
+ (WebCore::SQLiteFileSystem::openDatabase):
+ * platform/text/PlatformString.h:
+ * platform/text/String.cpp:
+ (WebCore::String::charactersWithNullTermination):
+ * platform/text/StringImpl.cpp:
+ (WebCore::StringImpl::operator new):
+ (WebCore::StringImpl::operator delete):
+ (WebCore::StringImpl::StringImpl):
+ (WebCore::StringImpl::~StringImpl):
+ (WebCore::StringImpl::create):
+ (WebCore::StringImpl::createWithTerminatingNullCharacter):
+ (WebCore::StringImpl::crossThreadString):
+ (WebCore::StringImpl::sharedBuffer):
+ * platform/text/StringImpl.h:
+ (WebCore::StringImpl::hasTerminatingNullCharacter):
+ (WebCore::StringImpl::inTable):
+ (WebCore::StringImpl::setInTable):
+ (WebCore::StringImpl::):
+ * platform/win/ClipboardUtilitiesWin.cpp:
+ (WebCore::createGlobalData):
+ * storage/OriginUsageRecord.cpp:
+ (WebCore::OriginUsageRecord::addDatabase):
+ (WebCore::OriginUsageRecord::markDatabase):
+
+2010-01-18 Gavin Barraclough <barraclough at apple.com>
+
Reviewed by NOBODY (windows build fix).
* platform/win/ClipboardUtilitiesWin.cpp:
diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp
index 2ddc861..7aeb6d0 100644
--- a/WebCore/WebCore.base.exp
+++ b/WebCore/WebCore.base.exp
@@ -142,6 +142,7 @@ __ZN7WebCore10StringImpl7replaceEtt
__ZN7WebCore10StringImpl8endsWithEPS0_b
__ZN7WebCore10StringImplD1Ev
__ZN7WebCore10StringImplcvP8NSStringEv
+__ZN7WebCore10StringImpldlEPv
__ZN7WebCore10handCursorEv
__ZN7WebCore10setCookiesEPNS_8DocumentERKNS_4KURLERKNS_6StringE
__ZN7WebCore11BitmapImageC1EP7CGImagePNS_13ImageObserverE
diff --git a/WebCore/platform/sql/SQLiteFileSystem.cpp b/WebCore/platform/sql/SQLiteFileSystem.cpp
index c094847..8cd7e80 100644
--- a/WebCore/platform/sql/SQLiteFileSystem.cpp
+++ b/WebCore/platform/sql/SQLiteFileSystem.cpp
@@ -49,9 +49,8 @@ void SQLiteFileSystem::registerSQLiteVFS()
int SQLiteFileSystem::openDatabase(const String& fileName, sqlite3** database)
{
// SQLite expects a null terminator on its UTF-16 strings.
- OwnArrayPtr<const UChar> path;
- fileName.copyWithNullTermination(path);
- return sqlite3_open16(path.get(), database);
+ String path = fileName;
+ return sqlite3_open16(path.charactersWithNullTermination(), database);
}
String SQLiteFileSystem::getFileNameForNewDatabase(const String& dbDir, const String&,
diff --git a/WebCore/platform/sql/SQLiteStatement.cpp b/WebCore/platform/sql/SQLiteStatement.cpp
index a488d03..ac96034 100644
--- a/WebCore/platform/sql/SQLiteStatement.cpp
+++ b/WebCore/platform/sql/SQLiteStatement.cpp
@@ -63,9 +63,7 @@ int SQLiteStatement::prepare()
ASSERT(!m_isPrepared);
const void* tail;
LOG(SQLDatabase, "SQL - prepare - %s", m_query.ascii().data());
- if (!m_queryWithNullTermination)
- m_query.copyWithNullTermination(m_queryWithNullTermination);
- int error = sqlite3_prepare16_v2(m_database.sqlite3Handle(), m_queryWithNullTermination.get(), -1, &m_statement, &tail);
+ int error = sqlite3_prepare16_v2(m_database.sqlite3Handle(), m_query.charactersWithNullTermination(), -1, &m_statement, &tail);
if (error != SQLITE_OK)
LOG(SQLDatabase, "sqlite3_prepare16 failed (%i)\n%s\n%s", error, m_query.ascii().data(), sqlite3_errmsg(m_database.sqlite3Handle()));
#ifndef NDEBUG
diff --git a/WebCore/platform/sql/SQLiteStatement.h b/WebCore/platform/sql/SQLiteStatement.h
index 87dba54..e62b4f0 100644
--- a/WebCore/platform/sql/SQLiteStatement.h
+++ b/WebCore/platform/sql/SQLiteStatement.h
@@ -91,7 +91,6 @@ public:
private:
SQLiteDatabase& m_database;
String m_query;
- OwnArrayPtr<const UChar> m_queryWithNullTermination;
sqlite3_stmt* m_statement;
#ifndef NDEBUG
bool m_isPrepared;
diff --git a/WebCore/platform/sql/chromium/SQLiteFileSystemChromium.cpp b/WebCore/platform/sql/chromium/SQLiteFileSystemChromium.cpp
index a66ac9f..752c613 100644
--- a/WebCore/platform/sql/chromium/SQLiteFileSystemChromium.cpp
+++ b/WebCore/platform/sql/chromium/SQLiteFileSystemChromium.cpp
@@ -51,9 +51,8 @@ SQLiteFileSystem::SQLiteFileSystem()
int SQLiteFileSystem::openDatabase(const String& fileName, sqlite3** database)
{
if (!ChromiumBridge::sandboxEnabled()) {
- OwnArrayPtr<const UChar> path;
- fileName.copyWithNullTermination(path);
- return sqlite3_open16(path.get(), database);
+ String path = fileName;
+ return sqlite3_open16(path.charactersWithNullTermination(), database);
}
// open databases using the default VFS
diff --git a/WebCore/platform/text/PlatformString.h b/WebCore/platform/text/PlatformString.h
index 2f74c25..8a379be 100644
--- a/WebCore/platform/text/PlatformString.h
+++ b/WebCore/platform/text/PlatformString.h
@@ -26,7 +26,6 @@
// on systems without case-sensitive file systems.
#include "StringImpl.h"
-#include <wtf/OwnArrayPtr.h>
#ifdef __OBJC__
#include <objc/objc.h>
@@ -94,7 +93,7 @@ public:
unsigned length() const;
const UChar* characters() const;
- void copyWithNullTermination(OwnArrayPtr<const UChar>&) const;
+ const UChar* charactersWithNullTermination();
UChar operator[](unsigned i) const; // if i >= length(), returns 0
UChar32 characterStartingAt(unsigned) const; // Ditto.
diff --git a/WebCore/platform/text/String.cpp b/WebCore/platform/text/String.cpp
index 3eb75ec..04b04ab 100644
--- a/WebCore/platform/text/String.cpp
+++ b/WebCore/platform/text/String.cpp
@@ -329,15 +329,14 @@ const UChar* String::characters() const
return m_impl->characters();
}
-void String::copyWithNullTermination(OwnArrayPtr<const UChar>& result) const
+const UChar* String::charactersWithNullTermination()
{
if (!m_impl)
- CRASH();
- unsigned length = m_impl->length();
- UChar* buffer = new UChar[length + 1];
- memcpy(buffer, m_impl->characters(), length * sizeof(UChar));
- buffer[length] = 0;
- result.set(buffer);
+ return 0;
+ if (m_impl->hasTerminatingNullCharacter())
+ return m_impl->characters();
+ m_impl = StringImpl::createWithTerminatingNullCharacter(*m_impl);
+ return m_impl->characters();
}
String String::format(const char *format, ...)
diff --git a/WebCore/platform/text/StringImpl.cpp b/WebCore/platform/text/StringImpl.cpp
index f40d96b..3b61a0b 100644
--- a/WebCore/platform/text/StringImpl.cpp
+++ b/WebCore/platform/text/StringImpl.cpp
@@ -57,12 +57,31 @@ static inline void deleteUCharVector(const UChar* p)
fastFree(const_cast<UChar*>(p));
}
+// Some of the factory methods create buffers using fastMalloc.
+// We must ensure that all allocations of StringImpl are allocated using
+// fastMalloc so that we don't have mis-matched frees. We accomplish
+// this by overriding the new and delete operators.
+void* StringImpl::operator new(size_t size, void* address)
+{
+ if (address)
+ return address; // Allocating using an internal buffer
+ return fastMalloc(size);
+}
+
+void* StringImpl::operator new(size_t size)
+{
+ return fastMalloc(size);
+}
+
+void StringImpl::operator delete(void* address)
+{
+ fastFree(address);
+}
+
// This constructor is used only to create the empty string.
StringImpl::StringImpl()
: m_data(0)
- , m_sharedBuffer(0)
, m_length(0)
- , m_refCountAndFlags(s_refCountIncrement)
, m_hash(0)
{
// Ensure that the hash is computed so that AtomicStringHash can call existingHash()
@@ -73,9 +92,7 @@ StringImpl::StringImpl()
inline StringImpl::StringImpl(const UChar* characters, unsigned length)
: m_data(characters)
- , m_sharedBuffer(0)
, m_length(length)
- , m_refCountAndFlags(s_refCountIncrement)
, m_hash(0)
{
ASSERT(characters);
@@ -87,7 +104,7 @@ StringImpl::~StringImpl()
if (inTable())
AtomicString::remove(this);
if (!bufferIsInternal()) {
- SharedUChar* sharedBuffer = m_sharedBuffer;
+ SharedUChar* sharedBuffer = m_sharedBufferAndFlags.get();
if (sharedBuffer)
sharedBuffer->deref();
else
@@ -953,7 +970,7 @@ PassRefPtr<StringImpl> StringImpl::create(const JSC::UString& str)
if (sharedBuffer) {
PassRefPtr<StringImpl> impl = adoptRef(new StringImpl(str.data(), str.size()));
sharedBuffer->ref();
- impl->m_sharedBuffer = sharedBuffer;
+ impl->m_sharedBufferAndFlags.set(sharedBuffer);
return impl;
}
return StringImpl::create(str.data(), str.size());
@@ -969,6 +986,21 @@ JSC::UString StringImpl::ustring()
}
#endif
+PassRefPtr<StringImpl> StringImpl::createWithTerminatingNullCharacter(const StringImpl& string)
+{
+ // Use createUninitialized instead of 'new StringImpl' so that the string and its buffer
+ // get allocated in a single malloc block.
+ UChar* data;
+ int length = string.m_length;
+ RefPtr<StringImpl> terminatedString = createUninitialized(length + 1, data);
+ memcpy(data, string.m_data, length * sizeof(UChar));
+ data[length] = 0;
+ terminatedString->m_length--;
+ terminatedString->m_hash = string.m_hash;
+ terminatedString->m_sharedBufferAndFlags.setFlag(HasTerminatingNullCharacter);
+ return terminatedString.release();
+}
+
PassRefPtr<StringImpl> StringImpl::threadsafeCopy() const
{
// Special-case empty strings to make sure that per-thread empty string instance isn't returned.
@@ -982,7 +1014,7 @@ PassRefPtr<StringImpl> StringImpl::crossThreadString()
SharedUChar* shared = sharedBuffer();
if (shared) {
RefPtr<StringImpl> impl = adoptRef(new StringImpl(m_data, m_length));
- impl->m_sharedBuffer = shared->crossThreadCopy().releaseRef();
+ impl->m_sharedBufferAndFlags.set(shared->crossThreadCopy().releaseRef());
return impl.release();
}
@@ -995,9 +1027,9 @@ StringImpl::SharedUChar* StringImpl::sharedBuffer()
if (m_length < minLengthToShare || bufferIsInternal())
return 0;
- if (!m_sharedBuffer)
- m_sharedBuffer = SharedUChar::create(new OwnFastMallocPtr<UChar>(const_cast<UChar*>(m_data))).releaseRef();
- return m_sharedBuffer;
+ if (!m_sharedBufferAndFlags.get())
+ m_sharedBufferAndFlags.set(SharedUChar::create(new OwnFastMallocPtr<UChar>(const_cast<UChar*>(m_data))).releaseRef());
+ return m_sharedBufferAndFlags.get();
}
diff --git a/WebCore/platform/text/StringImpl.h b/WebCore/platform/text/StringImpl.h
index 219c73b..f7a9d06 100644
--- a/WebCore/platform/text/StringImpl.h
+++ b/WebCore/platform/text/StringImpl.h
@@ -26,8 +26,8 @@
#include <limits.h>
#include <wtf/ASCIICType.h>
#include <wtf/CrossThreadRefCounted.h>
-#include <wtf/Noncopyable.h>
#include <wtf/OwnFastMallocPtr.h>
+#include <wtf/PtrAndFlags.h>
#include <wtf/RefCounted.h>
#include <wtf/StringHashFunctions.h>
#include <wtf/Vector.h>
@@ -58,7 +58,7 @@ enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive };
typedef bool (*CharacterMatchFunctionPtr)(UChar);
-class StringImpl : public Noncopyable {
+class StringImpl : public RefCounted<StringImpl> {
friend struct CStringTranslator;
friend struct HashAndCharactersTranslator;
friend struct UCharBufferTranslator;
@@ -82,6 +82,8 @@ public:
static PassRefPtr<StringImpl> create(const char*);
static PassRefPtr<StringImpl> createUninitialized(unsigned length, UChar*& data);
+ static PassRefPtr<StringImpl> createWithTerminatingNullCharacter(const StringImpl&);
+
static PassRefPtr<StringImpl> createStrippingNullCharacters(const UChar*, unsigned length);
static PassRefPtr<StringImpl> adopt(StringBuffer&);
static PassRefPtr<StringImpl> adopt(Vector<UChar>&);
@@ -94,18 +96,16 @@ public:
const UChar* characters() { return m_data; }
unsigned length() { return m_length; }
- bool inTable() const { return m_refCountAndFlags & s_refCountFlagInTable; }
- void setInTable() { m_refCountAndFlags |= s_refCountFlagInTable; }
+ bool hasTerminatingNullCharacter() const { return m_sharedBufferAndFlags.isFlagSet(HasTerminatingNullCharacter); }
+
+ bool inTable() const { return m_sharedBufferAndFlags.isFlagSet(InTable); }
+ void setInTable() { return m_sharedBufferAndFlags.setFlag(InTable); }
unsigned hash() { if (m_hash == 0) m_hash = computeHash(m_data, m_length); return m_hash; }
unsigned existingHash() const { ASSERT(m_hash); return m_hash; }
inline static unsigned computeHash(const UChar* data, unsigned length) { return WTF::stringHash(data, length); }
inline static unsigned computeHash(const char* data) { return WTF::stringHash(data); }
- StringImpl* ref() { m_refCountAndFlags += s_refCountIncrement; return this; }
- ALWAYS_INLINE void deref() { m_refCountAndFlags -= s_refCountIncrement; if (!(m_refCountAndFlags & s_refCountMask)) delete this; }
- ALWAYS_INLINE bool hasOneRef() const { return (m_refCountAndFlags & s_refCountMask) == s_refCountIncrement; }
-
// Returns a StringImpl suitable for use on another thread.
PassRefPtr<StringImpl> crossThreadString();
// Makes a deep copy. Helpful only if you need to use a String on another thread
@@ -175,9 +175,13 @@ public:
operator NSString*();
#endif
+ void operator delete(void*);
+
private:
- using Noncopyable::operator new;
- void* operator new(size_t, void* inPlace) { ASSERT(inPlace); return inPlace; }
+ // Allocation from a custom buffer is only allowed internally to avoid
+ // mismatched allocators. Callers should use create().
+ void* operator new(size_t size);
+ void* operator new(size_t size, void* address);
static PassRefPtr<StringImpl> createStrippingNullCharactersSlowCase(const UChar*, unsigned length);
@@ -185,15 +189,15 @@ private:
// In this case, the m_data pointer is an "internal buffer", and does not need to be deallocated.
bool bufferIsInternal() { return m_data == reinterpret_cast<const UChar*>(this + 1); }
- static const unsigned s_refCountMask = 0xFFFFFFFE;
- static const unsigned s_refCountIncrement = 0x2;
- static const unsigned s_refCountFlagInTable = 0x1;
+ enum StringImplFlags {
+ HasTerminatingNullCharacter,
+ InTable,
+ };
const UChar* m_data;
- SharedUChar* m_sharedBuffer;
unsigned m_length;
- unsigned m_refCountAndFlags;
mutable unsigned m_hash;
+ PtrAndFlags<SharedUChar, StringImplFlags> m_sharedBufferAndFlags;
// There is a fictitious variable-length UChar array at the end, which is used
// as the internal buffer by the createUninitialized and create methods.
};
diff --git a/WebCore/platform/win/ClipboardUtilitiesWin.cpp b/WebCore/platform/win/ClipboardUtilitiesWin.cpp
index c14b18f..0358b7a 100644
--- a/WebCore/platform/win/ClipboardUtilitiesWin.cpp
+++ b/WebCore/platform/win/ClipboardUtilitiesWin.cpp
@@ -114,11 +114,7 @@ HGLOBAL createGlobalData(const KURL& url, const String& title)
if (cbData) {
PWSTR buffer = (PWSTR)::GlobalLock(cbData);
- OwnArrayPtr<const UChar> nullTerminatedURL;
- mutableURL.copyWithNullTermination(nullTerminatedURL);
- OwnArrayPtr<const UChar> nullTerminatedTitle;
- mutableTitle.copyWithNullTermination(nullTerminatedTitle);
- swprintf_s(buffer, size, L"%s\n%s", nullTerminatedURL.get(), nullTerminatedTitle.get());
+ swprintf_s(buffer, size, L"%s\n%s", mutableURL.charactersWithNullTermination(), mutableTitle.charactersWithNullTermination());
::GlobalUnlock(cbData);
}
return cbData;
diff --git a/WebCore/storage/OriginUsageRecord.cpp b/WebCore/storage/OriginUsageRecord.cpp
index 8128a1b..684df53 100644
--- a/WebCore/storage/OriginUsageRecord.cpp
+++ b/WebCore/storage/OriginUsageRecord.cpp
@@ -42,8 +42,8 @@ OriginUsageRecord::OriginUsageRecord()
void OriginUsageRecord::addDatabase(const String& identifier, const String& fullPath)
{
ASSERT(!m_databaseMap.contains(identifier));
- ASSERT_ARG(identifier, identifier.impl()->hasOneRef());
- ASSERT_ARG(fullPath, fullPath.impl()->hasOneRef());
+ ASSERT_ARG(identifier, identifier.impl()->refCount() == 1);
+ ASSERT_ARG(fullPath, fullPath.impl()->refCount() == 1);
m_databaseMap.set(identifier, DatabaseEntry(fullPath));
m_unknownSet.add(identifier);
@@ -63,7 +63,7 @@ void OriginUsageRecord::removeDatabase(const String& identifier)
void OriginUsageRecord::markDatabase(const String& identifier)
{
ASSERT(m_databaseMap.contains(identifier));
- ASSERT_ARG(identifier, identifier.impl()->hasOneRef());
+ ASSERT_ARG(identifier, identifier.impl()->refCount() == 1);
m_unknownSet.add(identifier);
m_cachedDiskUsageIsValid = false;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list