1 /* 2 // Copyright (C) 2022 Beken Corporation 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 #ifndef _MEM_PUB_H_ 16 #define _MEM_PUB_H_ 17 18 #include <stdarg.h> 19 #include <common/bk_typedef.h> 20 #include <common/sys_config.h> 21 #ifdef __cplusplus 22 extern"C" { 23 #endif 24 25 INT32 os_memcmp(const void *s1, const void *s2, UINT32 n); 26 void *os_memmove(void *out, const void *in, UINT32 n); 27 void *os_memcpy(void *out, const void *in, UINT32 n); 28 void *os_memset(void *b, int c, UINT32 len); 29 void os_mem_init(void); 30 void *os_realloc(void *ptr, size_t size); 31 int os_memcmp_const(const void *a, const void *b, size_t len); 32 33 #if (CONFIG_MALLOC_STATIS || CONFIG_MEM_DEBUG) 34 void *os_malloc_debug(const char *func_name, int line, size_t size, int need_zero); 35 void *psram_malloc_debug(const char *func_name, int line, size_t size, int need_zero); 36 void *os_free_debug(const char *func_name, int line, void *pv); 37 void os_dump_memory_stats(uint32_t start_tick, uint32_t ticks_since_malloc, const char* task); 38 39 #define os_malloc(size) os_malloc_debug((const char*)__FUNCTION__,__LINE__,size, 0) 40 #define os_free(p) os_free_debug((const char*)__FUNCTION__,__LINE__, p) 41 #define os_zalloc(size) os_malloc_debug((const char*)__FUNCTION__,__LINE__,size, 1) 42 #define psram_malloc(size) psram_malloc_debug((const char*)__FUNCTION__,__LINE__,size, 0) 43 #define psram_zalloc(size) psram_malloc_debug((const char*)__FUNCTION__,__LINE__,size, 1) 44 #else 45 void *os_malloc(size_t size); 46 void os_free(void *ptr); 47 void *os_zalloc(size_t size); 48 void *psram_malloc(size_t size); 49 void *psram_zalloc(size_t size); 50 #endif 51 //#define psram_free os_free 52 53 void* os_malloc_wifi_buffer(size_t size); 54 void os_show_memory_config_info(void); 55 #ifdef __cplusplus 56 } 57 #endif 58 59 #endif // _MEM_PUB_H_ 60 61 // EOF 62