diff --git a/third_party/musl/ndk_musl_include/malloc.h b/third_party/musl/ndk_musl_include/malloc.h index 4817d5a5ebf8ad655c947b290d2771779043beb0..3601b2625b7b4a62a346e1ff69358bced9a35d71 100644 --- a/third_party/musl/ndk_musl_include/malloc.h +++ b/third_party/musl/ndk_musl_include/malloc.h @@ -1,3 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @addtogroup MuslMalloc + * @{ + * + * @brief Provide some methods related to memory management. + * @since 12 + */ +/** + * @file malloc.h + * + * @brief Includes some memory-related methods and structures, + * such as: malloc, calloc, realloc, and so on. + * + * @library libc.so + * @kit CstandardLibrary + * @since 12 + */ + #ifndef _MALLOC_H #define _MALLOC_H @@ -35,6 +67,17 @@ void *memalign(size_t, size_t); size_t malloc_usable_size(void *); int mallopt(int param, int value); +/** + * @brief This function determines whether a given memory block was allocated using + * Standard C library Memory Allocator. + * This function is MT-Safe(multi-thread safe) but not signal-safe. + * @param {void *} ptr A pointer to the memory block to be checked. + * @return 1 - The memory block was allocated using Standard C library Memory Allocator. + * 0 - The memory block was not allocated using Standard C library Memory Allocator. + * -1 - The function is not implemented or other error. + */ +int malloc_check_from_ptr(void *ptr); + struct mallinfo { int arena; int ordblks; @@ -66,3 +109,4 @@ struct mallinfo2 { #endif #endif +/** @} */ \ No newline at end of file diff --git a/third_party/musl/ndk_script/adapter/libc.ndk.json b/third_party/musl/ndk_script/adapter/libc.ndk.json index 4a86a82df107f76a5c8e4da3cf210456a4b94a51..c1dfaf89df45277c7dad80084b0672b793e811bf 100644 --- a/third_party/musl/ndk_script/adapter/libc.ndk.json +++ b/third_party/musl/ndk_script/adapter/libc.ndk.json @@ -1588,5 +1588,6 @@ { "name": "__recv_chk"}, { "name": "__recvfrom_chk"}, { "name": "__open_chk"}, - { "name": "__strlcat_chk"} + { "name": "__strlcat_chk"}, + { "name": "malloc_check_from_ptr"} ]