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"
11 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h"
12 #include "mojo/public/cpp/environment/logging.h"
17 FixedBuffer::FixedBuffer(size_t size
)
20 size_(internal::Align(size
)) {
21 // calloc() required to zero memory and thus avoid info leaks.
22 ptr_
= static_cast<char*>(calloc(size_
, 1));
25 FixedBuffer::~FixedBuffer() {
29 void* FixedBuffer::Allocate(size_t delta
) {
30 delta
= internal::Align(delta
);
32 if (delta
== 0 || delta
> size_
- cursor_
) {
33 MOJO_DCHECK(false) << "Not reached";
37 char* result
= ptr_
+ cursor_
;
43 void* FixedBuffer::Leak() {
51 } // namespace internal