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/cpp/bindings/lib/fixed_buffer.h"
13 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h"
18 FixedBuffer::FixedBuffer(size_t size)
21 size_(internal::Align(size)) {
22 // calloc() required to zero memory and thus avoid info leaks.
23 ptr_ = static_cast<char*>(calloc(size_, 1));
26 FixedBuffer::~FixedBuffer() {
30 void* FixedBuffer::Allocate(size_t delta, Destructor dtor) {
33 delta = internal::Align(delta);
35 if (delta == 0 || delta > size_ - cursor_) {
40 char* result = ptr_ + cursor_;
46 void* FixedBuffer::Leak() {
54 } // namespace internal