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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 { | 115 { |
116 ArrayBufferContents contents(byteLength, 1, ArrayBufferContents::NotShared,
ArrayBufferContents::ZeroInitialize); | 116 ArrayBufferContents contents(byteLength, 1, ArrayBufferContents::NotShared,
ArrayBufferContents::ZeroInitialize); |
117 RELEASE_ASSERT(contents.data()); | 117 RELEASE_ASSERT(contents.data()); |
118 RefPtr<ArrayBuffer> buffer = adoptRef(new ArrayBuffer(contents)); | 118 RefPtr<ArrayBuffer> buffer = adoptRef(new ArrayBuffer(contents)); |
119 memcpy(buffer->data(), source, byteLength); | 119 memcpy(buffer->data(), source, byteLength); |
120 return buffer.release(); | 120 return buffer.release(); |
121 } | 121 } |
122 | 122 |
123 PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBufferContents& contents) | 123 PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBufferContents& contents) |
124 { | 124 { |
| 125 RELEASE_ASSERT(contents.data()); |
125 return adoptRef(new ArrayBuffer(contents)); | 126 return adoptRef(new ArrayBuffer(contents)); |
126 } | 127 } |
127 | 128 |
128 PassRefPtr<ArrayBuffer> ArrayBuffer::createOrNull(unsigned numElements, unsigned
elementByteSize) | 129 PassRefPtr<ArrayBuffer> ArrayBuffer::createOrNull(unsigned numElements, unsigned
elementByteSize) |
129 { | 130 { |
130 return createOrNull(numElements, elementByteSize, ArrayBufferContents::ZeroI
nitialize); | 131 return createOrNull(numElements, elementByteSize, ArrayBufferContents::ZeroI
nitialize); |
131 } | 132 } |
132 | 133 |
133 PassRefPtr<ArrayBuffer> ArrayBuffer::createUninitialized(unsigned numElements, u
nsigned elementByteSize) | 134 PassRefPtr<ArrayBuffer> ArrayBuffer::createUninitialized(unsigned numElements, u
nsigned elementByteSize) |
134 { | 135 { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 if (index < 0) | 218 if (index < 0) |
218 index = currentLength + index; | 219 index = currentLength + index; |
219 return clampValue(index, 0, currentLength); | 220 return clampValue(index, 0, currentLength); |
220 } | 221 } |
221 | 222 |
222 } // namespace WTF | 223 } // namespace WTF |
223 | 224 |
224 using WTF::ArrayBuffer; | 225 using WTF::ArrayBuffer; |
225 | 226 |
226 #endif // ArrayBuffer_h | 227 #endif // ArrayBuffer_h |
OLD | NEW |