added null check to destructors

This commit is contained in:
Timerix 2025-11-09 03:37:17 +05:00
parent d6436d0833
commit 2c8e6fc601
2 changed files with 6 additions and 0 deletions

View File

@ -22,6 +22,9 @@ void HashMap_construct_size(HashMap_* ptr, u32 value_t_size, FreeFunction NULLAB
}
void HashMap_destroy(HashMap_* ptr){
if(!ptr)
return;
for(u32 i = 0; i < ptr->height; i++){
HashMapBucket* bu = &ptr->table[i];
u32 len = List_len(&bu->key_hash_list, KeyHash);

View File

@ -1,6 +1,9 @@
#include "tlibc/string/StringBuilder.h"
void StringBuilder_destroy(StringBuilder* b){
if(!b)
return;
free(b->buffer.data);
b->buffer = List_construct_size(NULL, 0, 0);
}