1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __OHOS_MALLOC_HOOK_CLIENT_H__ 17 #define __OHOS_MALLOC_HOOK_CLIENT_H__ 18 19 #include <cstdlib> 20 #include "musl_malloc_dispatch.h" 21 22 #define EXPORT_API __attribute__((visibility("default"))) 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 EXPORT_API bool ohos_malloc_hook_initialize(const MallocDispatchType*, bool*, const char*); 29 EXPORT_API bool ohos_malloc_hook_get_hook_flag(void); 30 EXPORT_API bool ohos_malloc_hook_set_hook_flag(bool); 31 EXPORT_API void ohos_malloc_hook_finalize(void); 32 EXPORT_API bool ohos_malloc_hook_on_start(void); 33 EXPORT_API bool ohos_malloc_hook_on_end(void); 34 EXPORT_API void* ohos_malloc_hook_malloc(size_t); 35 EXPORT_API void* ohos_malloc_hook_realloc(void*, size_t); 36 EXPORT_API void* ohos_malloc_hook_calloc(size_t, size_t); 37 EXPORT_API void* ohos_malloc_hook_valloc(size_t); 38 EXPORT_API void ohos_malloc_hook_free(void*); 39 EXPORT_API void* ohos_malloc_hook_memalign(size_t, size_t); 40 EXPORT_API size_t ohos_malloc_hook_malloc_usable_size(void*); 41 EXPORT_API void* ohos_malloc_hook_mmap(void*, size_t, int, int, int, off_t); 42 EXPORT_API int ohos_malloc_hook_munmap(void*, size_t); 43 EXPORT_API void ohos_malloc_hook_memtrace(void*, size_t, const char*, bool); 44 EXPORT_API int ohos_malloc_hook_prctl(int option, unsigned long, unsigned long, unsigned long, unsigned long); 45 EXPORT_API bool ohos_set_filter_size(size_t size, void* ret); 46 47 #ifdef __cplusplus 48 } 49 #endif 50 51 52 #endif /* __OHOS_MALLOC_HOOK_CLIENT_H__ */