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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 return; | 66 return; |
67 } | 67 } |
68 if (newLength > m_data->length()) { | 68 if (newLength > m_data->length()) { |
69 CharType* characters; | 69 CharType* characters; |
70 m_data = StringImpl::reallocate(m_data.release(), newLength, charact
ers); | 70 m_data = StringImpl::reallocate(m_data.release(), newLength, charact
ers); |
71 return; | 71 return; |
72 } | 72 } |
73 shrink(newLength); | 73 shrink(newLength); |
74 } | 74 } |
75 | 75 |
76 unsigned length() const { return m_data->length(); } | 76 unsigned length() const { return m_data ? m_data->length() : 0; } |
77 CharType* characters() { return length() ? const_cast<CharType*>(m_data->get
Characters<CharType>()) : 0; } | 77 CharType* characters() { return length() ? const_cast<CharType*>(m_data->get
Characters<CharType>()) : 0; } |
78 | 78 |
79 CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < leng
th()); return characters()[i]; } | 79 CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < leng
th()); return characters()[i]; } |
80 | 80 |
81 PassRefPtr<StringImpl> release() { return m_data.release(); } | 81 PassRefPtr<StringImpl> release() { return m_data.release(); } |
82 | 82 |
83 private: | 83 private: |
84 RefPtr<StringImpl> m_data; | 84 RefPtr<StringImpl> m_data; |
85 }; | 85 }; |
86 | 86 |
87 } // namespace WTF | 87 } // namespace WTF |
88 | 88 |
89 using WTF::StringBuffer; | 89 using WTF::StringBuffer; |
90 | 90 |
91 #endif // StringBuffer_h | 91 #endif // StringBuffer_h |
OLD | NEW |