format using clang-format to formate code

This commit is contained in:
zzy
2025-11-20 17:55:08 +08:00
parent 9762cf8a2b
commit d1fafa830d
27 changed files with 1047 additions and 766 deletions

View File

@@ -1,6 +1,6 @@
#include "strpool.h"
u32 rt_strhash(const char* s) {
u32 rt_strhash(const char *s) {
u32 hash = 2166136261u; // FNV-1a偏移基础值
while (*s) {
hash ^= *s++;
@@ -9,7 +9,7 @@ u32 rt_strhash(const char* s) {
return hash;
}
int rt_strcmp(const char* s1, const char* s2) {
int rt_strcmp(const char *s1, const char *s2) {
while (*s1 && *s2 && *s1 == *s2) {
s1++;
s2++;
@@ -17,20 +17,20 @@ int rt_strcmp(const char* s1, const char* s2) {
return *s1 - *s2;
}
void init_strpool(strpool_t* pool) {
pool->ht.hash_func = (u32(*)(const void*))rt_strhash;
pool->ht.key_cmp = (int(*)(const void*, const void*))rt_strcmp;
void init_strpool(strpool_t *pool) {
pool->ht.hash_func = (u32 (*)(const void *))rt_strhash;
pool->ht.key_cmp = (int (*)(const void *, const void *))rt_strcmp;
init_hashtable(&pool->ht);
}
const char* strpool_intern(strpool_t* pool, const char* str) {
void* existing = hashtable_get(&pool->ht, str);
const char *strpool_intern(strpool_t *pool, const char *str) {
void *existing = hashtable_get(&pool->ht, str);
if (existing) {
return existing;
}
rt_size_t len = rt_strlen(str) + 1;
char* new_str = lalloc_alloc(&pool->stralloc, len);
char *new_str = lalloc_alloc(&pool->stralloc, len);
if (!new_str) {
LOG_ERROR("strpool: Failed to allocate memory for string");
return NULL;
@@ -41,7 +41,7 @@ const char* strpool_intern(strpool_t* pool, const char* str) {
return new_str;
}
void strpool_destroy(strpool_t* pool) {
void strpool_destroy(strpool_t *pool) {
hashtable_destory(&pool->ht);
lalloc_destroy(&pool->stralloc);
}