1 /** 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 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 * Description: dbg hash tab header file\n 16 * 17 * History: \n 18 * 2022-09-16, Create file. \n 19 */ 20 #ifndef __DBG_HASH_TAB_H__ 21 #define __DBG_HASH_TAB_H__ 22 #ifdef _DEBUG_HEAP_MEM_MGR 23 24 #include <stdint.h> 25 #include "osal_list.h" 26 27 #ifdef __cplusplus 28 #if __cplusplus 29 extern "C" { 30 #endif 31 #endif 32 33 #define HEAP_HASH_SIZE 0x40 // 64 34 35 typedef struct dbg_hash_data { 36 void *key; 37 uint32_t length; 38 #ifdef __GNUC__ 39 uint32_t master; 40 #endif 41 struct osal_list_head list; 42 } dbg_hash_data; 43 44 typedef uint32_t (*hash_func)(const void *ptr, size_t tab_len); 45 46 typedef struct dbg_hash_tab { 47 struct osal_list_head table[HEAP_HASH_SIZE]; 48 uint32_t tab_len; 49 struct osal_list_head free_head; 50 hash_func hash_key_func; 51 } dbg_hash_tab; 52 53 /******************* func *******************/ 54 void hash_mem_add(dbg_hash_tab *hash_tab, void *ptr, uint32_t value, uint32_t master); 55 uint32_t hash_mem_delete(dbg_hash_tab *hash_tab, void *ptr); 56 57 #ifdef __cplusplus 58 #if __cplusplus 59 } 60 #endif 61 #endif 62 #endif 63 #endif