1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "mojo/public/bindings/lib/fixed_buffer.h"
13 #include "mojo/public/bindings/lib/bindings_serialization.h"
18 FixedBuffer::FixedBuffer(size_t size)
21 size_(internal::Align(size)) {
22 ptr_ = static_cast<char*>(calloc(size_, 1));
25 FixedBuffer::~FixedBuffer() {
29 void* FixedBuffer::Allocate(size_t delta, Destructor dtor) {
32 delta = internal::Align(delta);
34 // TODO(darin): Using <assert.h> is probably not going to cut it.
36 assert(cursor_ + delta <= size_);
37 if (cursor_ + delta > size_)
40 char* result = ptr_ + cursor_;
46 void* FixedBuffer::Leak() {
54 } // namespace internal