smcc/lib/utils/ds/hashtable.h
ZZY 05c637e594 refactor: 重构前端代码并添加日志功能
- 重命名和重构了多个文件,包括 lexer、parser 和 AST 相关代码
- 添加了日志功能,使用 LOG_* 宏替代原有的 error 和 warn 函数
- 优化了错误处理和内存分配方式
- 调整了代码结构,提高了模块化和可读性
2025-03-19 12:22:55 +08:00

28 lines
664 B
C

#ifndef __SMCC_HASHTABLE_H__
#define __SMCC_HASHTABLE_H__
#include <lib/rt/rt.h>
typedef struct hash_node {
const char* str;
int len;
u32_t hash;
struct hash_node* next;
} hash_node_t;
typedef struct hash_table {
hash_node_t** buckets;
int size;
int cap;
int max_cap;
} hash_table_t;
hash_table_t* new_hash_table(int init_size, int max_cap);
void hash_table_init(hash_table_t* ht, int init_size, int max_cap);
void hash_table_destroy(hash_table_t* ht);
void hash_table_insert(hash_table_t* ht, const char* str, int len);
hash_node_t* hash_table_find(hash_table_t* ht, const char* str, int len);
#endif // __SMCC_HASHTABLE_H__