1 /*
2  * Copyright 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * Generated mock file from original source file
19  *   Functions generated:6
20  *
21  *  mockcify.pl ver 0.3.0
22  */
23 // Mock include file to share data between tests and mock
24 #include "test/mock/mock_osi_allocator.h"
25 
26 #include "osi/include/allocator.h"
27 #include "test/common/mock_functions.h"
28 
29 // Mocked internal structures, if any
30 
OsiObject(void * ptr)31 OsiObject::OsiObject(void* ptr) : ptr_(ptr) {}
32 
OsiObject(const void * ptr)33 OsiObject::OsiObject(const void* ptr) : ptr_(const_cast<void*>(ptr)) {}
34 
~OsiObject()35 OsiObject::~OsiObject() {
36   if (ptr_ != nullptr) {
37     osi_free(ptr_);
38   }
39 }
40 
Release()41 void* OsiObject::Release() {
42   void* ptr = ptr_;
43   ptr_ = nullptr;
44   return ptr;
45 }
46 namespace test {
47 namespace mock {
48 namespace osi_allocator {
49 
50 // Function state capture and return values, if needed
51 struct osi_calloc osi_calloc;
52 struct osi_free osi_free;
53 struct osi_free_and_reset osi_free_and_reset;
54 struct osi_malloc osi_malloc;
55 struct osi_strdup osi_strdup;
56 struct osi_strndup osi_strndup;
57 
58 }  // namespace osi_allocator
59 }  // namespace mock
60 }  // namespace test
61 
62 // Mocked functions, if any
osi_calloc(size_t size)63 void* osi_calloc(size_t size) {
64   inc_func_call_count(__func__);
65   return test::mock::osi_allocator::osi_calloc(size);
66 }
osi_free(void * ptr)67 void osi_free(void* ptr) {
68   inc_func_call_count(__func__);
69   test::mock::osi_allocator::osi_free(ptr);
70 }
osi_free_and_reset(void ** p_ptr)71 void osi_free_and_reset(void** p_ptr) {
72   inc_func_call_count(__func__);
73   test::mock::osi_allocator::osi_free_and_reset(p_ptr);
74 }
osi_malloc(size_t size)75 void* osi_malloc(size_t size) {
76   inc_func_call_count(__func__);
77   return test::mock::osi_allocator::osi_malloc(size);
78 }
osi_strdup(const char * str)79 char* osi_strdup(const char* str) {
80   inc_func_call_count(__func__);
81   return test::mock::osi_allocator::osi_strdup(str);
82 }
osi_strndup(const char * str,size_t len)83 char* osi_strndup(const char* str, size_t len) {
84   inc_func_call_count(__func__);
85   return test::mock::osi_allocator::osi_strndup(str, len);
86 }
87 // Mocked functions complete
88 // END mockcify generation
89