OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 <cstdlib> | |
6 | |
7 #include "base/logging.h" | |
8 #include "services/media/framework/allocator.h" | |
9 | |
10 namespace mojo { | |
11 namespace media { | |
12 | |
13 namespace { | |
14 | |
15 class DefaultAllocator : public Allocator { | |
16 public: | |
17 // Allocator implementation. | |
18 void* AllocatePayloadBuffer(uint64_t size) override; | |
19 | |
20 void ReleasePayloadBuffer(uint64_t size, void* buffer) override; | |
21 }; | |
22 | |
23 void* DefaultAllocator::AllocatePayloadBuffer(uint64_t size) { | |
24 DCHECK(size > 0); | |
25 return std::malloc(static_cast<size_t>(size)); | |
26 } | |
27 | |
28 void DefaultAllocator::ReleasePayloadBuffer(uint64_t size, void* buffer) { | |
29 DCHECK(size > 0); | |
30 DCHECK(buffer); | |
31 std::free(buffer); | |
32 } | |
33 | |
34 static DefaultAllocator default_allocator; | |
johngro
2016/01/20 00:25:32
I think that static-scoped classes are supposed to
dalesat
2016/01/25 23:29:37
I'm not sure what to do here in that case. I can't
johngro
2016/01/27 22:35:22
const_cast is your friend. I banged out a simple
dalesat
2016/01/28 18:49:15
Done.
| |
35 | |
36 } // namespace | |
37 | |
38 // static | |
39 Allocator* Allocator::GetDefault() { | |
40 return &default_allocator; | |
41 } | |
42 | |
43 } // namespace media | |
44 } // namespace mojo | |
OLD | NEW |