| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include "ppapi/c/dev/ppb_memory_dev.h" | 7 #include "ppapi/c/dev/ppb_memory_dev.h" |
| 8 #include "ppapi/shared_impl/ppapi_shared_export.h" | 8 #include "ppapi/shared_impl/ppapi_shared_export.h" |
| 9 | 9 |
| 10 // The memory interface doesn't have a normal C -> C++ thunk since it doesn't | 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 | 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 | 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. | 13 // namespace so it magically gets hooked up in the proper places. |
| 14 | 14 |
| 15 namespace ppapi { | 15 namespace ppapi { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 void* MemAlloc(uint32_t num_bytes) { | 19 void* MemAlloc(uint32_t num_bytes) { return malloc(num_bytes); } |
| 20 return malloc(num_bytes); | |
| 21 } | |
| 22 | 20 |
| 23 void MemFree(void* ptr) { | 21 void MemFree(void* ptr) { free(ptr); } |
| 24 free(ptr); | |
| 25 } | |
| 26 | 22 |
| 27 const PPB_Memory_Dev ppb_memory = { | 23 const PPB_Memory_Dev ppb_memory = {&MemAlloc, &MemFree}; |
| 28 &MemAlloc, | |
| 29 &MemFree | |
| 30 }; | |
| 31 | 24 |
| 32 } // namespace | 25 } // namespace |
| 33 | 26 |
| 34 namespace thunk { | 27 namespace thunk { |
| 35 | 28 |
| 36 // static | 29 // static |
| 37 PPAPI_SHARED_EXPORT const PPB_Memory_Dev_0_1* GetPPB_Memory_Dev_0_1_Thunk() { | 30 PPAPI_SHARED_EXPORT const PPB_Memory_Dev_0_1* GetPPB_Memory_Dev_0_1_Thunk() { |
| 38 return &ppb_memory; | 31 return &ppb_memory; |
| 39 } | 32 } |
| 40 | 33 |
| 41 } // namespace thunk | 34 } // namespace thunk |
| 42 | 35 |
| 43 } // namespace ppapi | 36 } // namespace ppapi |
| OLD | NEW |