1 /*
2  * Copyright (C) 2020 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 #ifndef SRC_PROFILING_MEMORY_WRAP_ALLOCATORS_H_
18 #define SRC_PROFILING_MEMORY_WRAP_ALLOCATORS_H_
19 
20 #include <inttypes.h>
21 #include <stdlib.h>
22 
23 namespace perfetto {
24 namespace profiling {
25 
26 void* wrap_malloc(uint32_t heap_id, void* (*fn)(size_t), size_t size);
27 void* wrap_calloc(uint32_t heap_id,
28                   void* (*fn)(size_t, size_t),
29                   size_t nmemb,
30                   size_t size);
31 void* wrap_memalign(uint32_t heap_id,
32                     void* (*fn)(size_t, size_t),
33                     size_t alignment,
34                     size_t size);
35 int wrap_posix_memalign(uint32_t heap_id,
36                         int (*fn)(void**, size_t, size_t),
37                         void** memptr,
38                         size_t alignment,
39                         size_t size);
40 void wrap_free(uint32_t heap_id, void (*fn)(void*), void* pointer);
41 void* wrap_realloc(uint32_t heap_id,
42                    void* (*fn)(void*, size_t),
43                    void* pointer,
44                    size_t size);
45 void* wrap_pvalloc(uint32_t heap_id, void* (*fn)(size_t), size_t size);
46 void* wrap_valloc(uint32_t heap_id, void* (*fn)(size_t), size_t size);
47 
48 void* wrap_reallocarray(uint32_t heap_id,
49                         void* (*fn)(void*, size_t, size_t),
50                         void* pointer,
51                         size_t nmemb,
52                         size_t size);
53 
54 }  // namespace profiling
55 }  // namespace perfetto
56 
57 #endif  // SRC_PROFILING_MEMORY_WRAP_ALLOCATORS_H_
58