blob: 57d52f037c489820c7fb1611d1fb3c851c30c279 [file] [log] [blame]
[email protected]256513872012-01-05 15:41:521// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]8d770e492011-10-11 04:54:312// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <stdlib.h>
6
7#include "ppapi/c/dev/ppb_memory_dev.h"
8#include "ppapi/shared_impl/ppapi_shared_export.h"
9
10// The memory interface doesn't have a normal C -> C++ thunk since it doesn't
11// actually have any proxy wrapping or associated objects; it's just a call
12// into base. So we implement the entire interface here, using the thunk
13// namespace so it magically gets hooked up in the proper places.
14
15namespace ppapi {
16
17namespace {
18
19void* MemAlloc(uint32_t num_bytes) {
20 return malloc(num_bytes);
21}
22
23void MemFree(void* ptr) {
24 free(ptr);
25}
26
27const PPB_Memory_Dev ppb_memory = {
28 &MemAlloc,
29 &MemFree
30};
31
32} // namespace
33
34namespace thunk {
35
36// static
[email protected]256513872012-01-05 15:41:5237PPAPI_SHARED_EXPORT const PPB_Memory_Dev_0_1* GetPPB_Memory_Dev_0_1_Thunk() {
[email protected]8d770e492011-10-11 04:54:3138 return &ppb_memory;
39}
40
41} // namespace thunk
42
43} // namespace ppapi