| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 T* data() { return m_alignedData; } | 105 T* data() { return m_alignedData; } |
| 106 const T* data() const { return m_alignedData; } | 106 const T* data() const { return m_alignedData; } |
| 107 size_t size() const { return m_size; } | 107 size_t size() const { return m_size; } |
| 108 | 108 |
| 109 T& at(size_t i) { | 109 T& at(size_t i) { |
| 110 // Note that although it is a size_t, m_size is now guaranteed to be | 110 // Note that although it is a size_t, m_size is now guaranteed to be |
| 111 // no greater than max unsigned. This guarantee is enforced in allocate(). | 111 // no greater than max unsigned. This guarantee is enforced in allocate(). |
| 112 ASSERT_WITH_SECURITY_IMPLICATION(i < size()); | 112 SECURITY_DCHECK(i < size()); |
| 113 return data()[i]; | 113 return data()[i]; |
| 114 } | 114 } |
| 115 | 115 |
| 116 T& operator[](size_t i) { return at(i); } | 116 T& operator[](size_t i) { return at(i); } |
| 117 | 117 |
| 118 void zero() { | 118 void zero() { |
| 119 // This multiplication is made safe by the check in allocate(). | 119 // This multiplication is made safe by the check in allocate(). |
| 120 memset(this->data(), 0, sizeof(T) * this->size()); | 120 memset(this->data(), 0, sizeof(T) * this->size()); |
| 121 } | 121 } |
| 122 | 122 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 152 T* m_alignedData; | 152 T* m_alignedData; |
| 153 size_t m_size; | 153 size_t m_size; |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 typedef AudioArray<float> AudioFloatArray; | 156 typedef AudioArray<float> AudioFloatArray; |
| 157 typedef AudioArray<double> AudioDoubleArray; | 157 typedef AudioArray<double> AudioDoubleArray; |
| 158 | 158 |
| 159 } // namespace blink | 159 } // namespace blink |
| 160 | 160 |
| 161 #endif // AudioArray_h | 161 #endif // AudioArray_h |
| OLD | NEW |