• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
6 
7 #include <stdlib.h>
8 
9 namespace mojo {
10 namespace internal {
11 
FixedBufferForTesting(size_t size)12 FixedBufferForTesting::FixedBufferForTesting(size_t size) {
13   size = internal::Align(size);
14   // Use calloc here to ensure all message memory is zero'd out.
15   void* ptr = calloc(size, 1);
16   Initialize(ptr, size);
17 }
18 
~FixedBufferForTesting()19 FixedBufferForTesting::~FixedBufferForTesting() {
20   free(data());
21 }
22 
Leak()23 void* FixedBufferForTesting::Leak() {
24   void* ptr = data();
25   Initialize(nullptr, 0);
26   return ptr;
27 }
28 
29 }  // namespace internal
30 }  // namespace mojo
31