OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (newLength > m_data->length()) { | 63 if (newLength > m_data->length()) { |
64 RELEASE_ASSERT(newLength <= std::numeric_limits<unsigned>::max() / s
izeof(UChar)); | 64 RELEASE_ASSERT(newLength <= std::numeric_limits<unsigned>::max() / s
izeof(UChar)); |
65 CharType* characters; | 65 CharType* characters; |
66 m_data = StringImpl::reallocate(m_data.release(), newLength, charact
ers); | 66 m_data = StringImpl::reallocate(m_data.release(), newLength, charact
ers); |
67 return; | 67 return; |
68 } | 68 } |
69 shrink(newLength); | 69 shrink(newLength); |
70 } | 70 } |
71 | 71 |
72 unsigned length() const { return m_data->length(); } | 72 unsigned length() const { return m_data->length(); } |
73 CharType* characters() { return const_cast<CharType*>(m_data->getCharacters<
CharType>()); } | 73 CharType* characters() { return length() ? const_cast<CharType*>(m_data->get
Characters<CharType>()) : 0; } |
74 | 74 |
75 CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < leng
th()); return characters()[i]; } | 75 CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < leng
th()); return characters()[i]; } |
76 | 76 |
77 PassRefPtr<StringImpl> release() { return m_data.release(); } | 77 PassRefPtr<StringImpl> release() { return m_data.release(); } |
78 | 78 |
79 private: | 79 private: |
80 RefPtr<StringImpl> m_data; | 80 RefPtr<StringImpl> m_data; |
81 }; | 81 }; |
82 | 82 |
83 } // namespace WTF | 83 } // namespace WTF |
84 | 84 |
85 using WTF::StringBuffer; | 85 using WTF::StringBuffer; |
86 | 86 |
87 #endif // StringBuffer_h | 87 #endif // StringBuffer_h |
OLD | NEW |