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 I18N_MEMORY_ADAPTER_H 17 #define I18N_MEMORY_ADAPTER_H 18 19 #ifdef __cplusplus 20 #define EXTERNC extern "C" 21 #else 22 #define EXTERNC 23 #endif 24 25 #ifndef I18N_PRODUCT 26 // memory operator define 27 #include <stdlib.h> 28 I18nMalloc(size_t size)29inline void *I18nMalloc(size_t size) 30 { 31 return malloc(size); 32 } 33 I18nFree(void * a)34inline void I18nFree(void *a) 35 { 36 if (a != nullptr) { 37 (void) free(a); 38 a = nullptr; 39 } 40 } 41 42 #else // I18N_PRODUCT 43 #include "stddef.h" 44 #include "stdint.h" 45 #include "ohos_mem_pool.h" 46 I18nMalloc(size_t size)47inline void *I18nMalloc(size_t size) 48 { 49 return OhosMalloc(MEM_TYPE_I18N_LSRAM, size); 50 } 51 I18nFree(void * a)52inline void I18nFree(void *a) 53 { 54 if (a != nullptr) { 55 (void) OhosFree(a); 56 a = nullptr; 57 } 58 } 59 60 #endif // I18N_PRODUCT 61 #endif // I18N_MEMORY_ADAPTER_H