Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: Source/wtf/ArrayBuffer.h

Issue 1302193002: Set ArrayBufferContents size to 0 on allocation failure (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/wtf/ArrayBufferContents.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/ArrayBufferContents.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698