1 /*
2  * Copyright (c) 2020-2022 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 /**
17  * @addtogroup UI_Utils
18  * @{
19  *
20  * @brief Defines basic UI utils.
21  *
22  * @since 1.0
23  * @version 1.0
24  */
25 
26 /**
27  * @file mem_api.h
28  *
29  * @brief Defines the functions for memory application and release. You can implement the <b>malloc</b> and <b>free</b>
30  *        functions to manage the memory.
31  *
32  * @since 1.0
33  * @version 1.0
34  */
35 
36 #ifndef GRAPHIC_LITE_MEM_API_H
37 #define GRAPHIC_LITE_MEM_API_H
38 
39 #include "gfx_utils/image_info.h"
40 
41 #include <cstdlib>
42 
43 namespace OHOS {
44 /**
45  * @brief Applies for the image cache memory. You can customize the memory area when loading image resources.
46  *
47  * @param info Indicates the image information. For details, see {@link ImageInfo}.
48  * @since 1.0
49  * @version 1.0
50  */
51 void* ImageCacheMalloc(const ImageInfo& info);
52 
53 /**
54  * @brief Releases the image cache memory.
55  *
56  * @param info Indicates the image information. For details, see {@link ImageInfo}.
57  * @since 1.0
58  * @version 1.0
59  */
60 void ImageCacheFree(ImageInfo& info);
61 
62 /**
63  * @brief Applies for memory for the graphics module. You can implement this function to override the <b>malloc</b> and
64  *        <b>new</b> functions.
65  *
66  * @param size Indicates the size of the memory to apply for.
67  * @since 1.0
68  * @version 1.0
69  */
70 void* UIMalloc(uint32_t size);
71 
72 /**
73  * @brief Releases memory for the graphics module. You can implement this function to override the <b>free</b> and
74  *        <b>delete</b> functions.
75  *
76  * @param buffer Indicates the pointer to the memory to be released.
77  * @since 1.0
78  * @version 1.0
79  */
80 void UIFree(void* buffer);
81 
82 /**
83  * @brief 重新调整之前调用UIMalloc所分配的内存指针所指向的内存块的大小
84  *
85  * @param buffer 指向内存区的指针
86  * @param size 分配的内存块大小
87  * @since 3.0
88  * @version 5.0
89  */
90 void* UIRealloc(void* buffer, uint32_t size);
91 } // namespace OHOS
92 #endif
93