OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) | 4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 130 } |
131 | 131 |
132 if (ownership == BufferInternal) | 132 if (ownership == BufferInternal) |
133 return; | 133 return; |
134 if (ownership == BufferOwned) { | 134 if (ownership == BufferOwned) { |
135 // We use m_data8, but since it is a union with m_data16 this works eith
er way. | 135 // We use m_data8, but since it is a union with m_data16 this works eith
er way. |
136 ASSERT(m_data8); | 136 ASSERT(m_data8); |
137 fastFree(const_cast<LChar*>(m_data8)); | 137 fastFree(const_cast<LChar*>(m_data8)); |
138 return; | 138 return; |
139 } | 139 } |
140 #if PLATFORM(QT) | |
141 if (ownership == BufferAdoptedQString) { | |
142 if (!m_qStringData->ref.deref()) | |
143 QStringData::deallocate(m_qStringData); | |
144 return; | |
145 } | |
146 #endif | |
147 | |
148 ASSERT(ownership == BufferSubstring); | 140 ASSERT(ownership == BufferSubstring); |
149 ASSERT(m_substringBuffer); | 141 ASSERT(m_substringBuffer); |
150 m_substringBuffer->deref(); | 142 m_substringBuffer->deref(); |
151 } | 143 } |
152 | 144 |
153 PassRefPtr<StringImpl> StringImpl::createFromLiteral(const char* characters, uns
igned length) | 145 PassRefPtr<StringImpl> StringImpl::createFromLiteral(const char* characters, uns
igned length) |
154 { | 146 { |
155 ASSERT_WITH_MESSAGE(length, "Use StringImpl::empty() to create an empty stri
ng"); | 147 ASSERT_WITH_MESSAGE(length, "Use StringImpl::empty() to create an empty stri
ng"); |
156 ASSERT(charactersAreAllASCII<LChar>(reinterpret_cast<const LChar*>(character
s), length)); | 148 ASSERT(charactersAreAllASCII<LChar>(reinterpret_cast<const LChar*>(character
s), length)); |
157 return adoptRef(new StringImpl(characters, length, ConstructFromLiteral)); | 149 return adoptRef(new StringImpl(characters, length, ConstructFromLiteral)); |
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 } | 1888 } |
1897 | 1889 |
1898 PassRefPtr<StringImpl> StringImpl::adopt(StringBuffer<UChar>& buffer) | 1890 PassRefPtr<StringImpl> StringImpl::adopt(StringBuffer<UChar>& buffer) |
1899 { | 1891 { |
1900 unsigned length = buffer.length(); | 1892 unsigned length = buffer.length(); |
1901 if (!length) | 1893 if (!length) |
1902 return empty(); | 1894 return empty(); |
1903 return adoptRef(new StringImpl(buffer.release(), length)); | 1895 return adoptRef(new StringImpl(buffer.release(), length)); |
1904 } | 1896 } |
1905 | 1897 |
1906 #if PLATFORM(QT) | |
1907 PassRefPtr<StringImpl> StringImpl::adopt(QStringData* qStringData) | |
1908 { | |
1909 ASSERT(qStringData); | |
1910 | |
1911 if (!qStringData->size) | |
1912 return empty(); | |
1913 | |
1914 return adoptRef(new StringImpl(qStringData, ConstructAdoptedQString)); | |
1915 } | |
1916 #endif | |
1917 | |
1918 PassRefPtr<StringImpl> StringImpl::createWithTerminatingNullCharacter(const Stri
ngImpl& string) | 1898 PassRefPtr<StringImpl> StringImpl::createWithTerminatingNullCharacter(const Stri
ngImpl& string) |
1919 { | 1899 { |
1920 // Use createUninitialized instead of 'new StringImpl' so that the string an
d its buffer | 1900 // Use createUninitialized instead of 'new StringImpl' so that the string an
d its buffer |
1921 // get allocated in a single memory block. | 1901 // get allocated in a single memory block. |
1922 unsigned length = string.m_length; | 1902 unsigned length = string.m_length; |
1923 if (length >= numeric_limits<unsigned>::max()) | 1903 if (length >= numeric_limits<unsigned>::max()) |
1924 CRASH(); | 1904 CRASH(); |
1925 RefPtr<StringImpl> terminatedString; | 1905 RefPtr<StringImpl> terminatedString; |
1926 if (string.is8Bit()) { | 1906 if (string.is8Bit()) { |
1927 LChar* data; | 1907 LChar* data; |
(...skipping 20 matching lines...) Expand all Loading... |
1948 size += 2 * size; | 1928 size += 2 * size; |
1949 if (hasTerminatingNullCharacter()) | 1929 if (hasTerminatingNullCharacter()) |
1950 size += 2; | 1930 size += 2; |
1951 } | 1931 } |
1952 } else | 1932 } else |
1953 size *= 2; | 1933 size *= 2; |
1954 return size + sizeof(*this); | 1934 return size + sizeof(*this); |
1955 } | 1935 } |
1956 | 1936 |
1957 } // namespace WTF | 1937 } // namespace WTF |
OLD | NEW |