1 /* 2 * Copyright (c) 2020-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 #include "gfx_utils/mem_api.h" 17 namespace OHOS { 18 #ifndef IMG_CACHE_MEMORY_CUSTOM ImageCacheMalloc(ImageInfo & info)19void* ImageCacheMalloc(ImageInfo& info) 20 { 21 return malloc(info.dataSize); 22 } 23 ImageCacheFree(ImageInfo & info)24void ImageCacheFree(ImageInfo& info) 25 { 26 uint8_t* buf = const_cast<uint8_t*>(info.data); 27 free(buf); 28 info.data = nullptr; 29 return; 30 } 31 #endif 32 33 #if !ENABLE_MEMORY_HOOKS UIMalloc(uint32_t size)34void* UIMalloc(uint32_t size) 35 { 36 return malloc(size); 37 } 38 UIFree(void * buffer)39void UIFree(void* buffer) 40 { 41 free(buffer); 42 } 43 UIRealloc(void * buffer,uint32_t size)44void* UIRealloc(void* buffer, uint32_t size) 45 { 46 return realloc(buffer, size); 47 } 48 #endif 49 } 50