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

Unified Diff: gpu/command_buffer/client/fenced_allocator.cc

Issue 11419280: Make FencedAlloctor fail on size = 0. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gpu/command_buffer/client/fenced_allocator_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/client/fenced_allocator.cc
diff --git a/gpu/command_buffer/client/fenced_allocator.cc b/gpu/command_buffer/client/fenced_allocator.cc
index d262115d7c1f10da8d000d8ef8e48f6fe7fd7e4c..0d395c41174f248d03f48e2ca19f7c50f7951b12 100644
--- a/gpu/command_buffer/client/fenced_allocator.cc
+++ b/gpu/command_buffer/client/fenced_allocator.cc
@@ -39,9 +39,11 @@ FencedAllocator::~FencedAllocator() {
// optimizing what to wait for, just looks inside the block in order (first-fit
// as well).
FencedAllocator::Offset FencedAllocator::Alloc(unsigned int size) {
- // Similarly to malloc, an allocation of 0 allocates at least 1 byte, to
- // return different pointers every time.
- if (size == 0) size = 1;
+ // size of 0 is not allowed because it would be inconsistent to only sometimes
+ // have it succeed. Example: Alloc(SizeOfBuffer), Alloc(0).
+ if (size == 0) {
+ return kInvalidOffset;
+ }
// Try first to allocate in a free block.
for (unsigned int i = 0; i < blocks_.size(); ++i) {
« no previous file with comments | « no previous file | gpu/command_buffer/client/fenced_allocator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698