OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2009 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 unsigned char get(unsigned index) const | 65 unsigned char get(unsigned index) const |
66 { | 66 { |
67 ASSERT(index < m_size); | 67 ASSERT(index < m_size); |
68 return m_data[index]; | 68 return m_data[index]; |
69 } | 69 } |
70 | 70 |
71 unsigned char* data() { return m_data; } | 71 unsigned char* data() { return m_data; } |
72 | 72 |
| 73 void clear() { memset(m_data, 0, m_size); } |
| 74 |
73 void deref() | 75 void deref() |
74 { | 76 { |
75 if (derefBase()) { | 77 if (derefBase()) { |
76 // We allocated with new unsigned char[] in create(), | 78 // We allocated with new unsigned char[] in create(), |
77 // and then used placement new to construct the object. | 79 // and then used placement new to construct the object. |
78 this->~ByteArray(); | 80 this->~ByteArray(); |
79 delete[] reinterpret_cast<unsigned char*>(this); | 81 delete[] reinterpret_cast<unsigned char*>(this); |
80 } | 82 } |
81 } | 83 } |
82 | 84 |
(...skipping 12 matching lines...) Expand all Loading... |
95 unsigned char m_data[INT_MAX]; | 97 unsigned char m_data[INT_MAX]; |
96 #else | 98 #else |
97 unsigned char m_data[]; | 99 unsigned char m_data[]; |
98 #endif | 100 #endif |
99 }; | 101 }; |
100 } // namespace WTF | 102 } // namespace WTF |
101 | 103 |
102 using WTF::ByteArray; | 104 using WTF::ByteArray; |
103 | 105 |
104 #endif | 106 #endif |
OLD | NEW |