Array_free

This commit is contained in:
Timerix 2025-11-18 12:16:46 +05:00
parent 425794361b
commit 89aab2b5bf
3 changed files with 9 additions and 1 deletions

View File

@ -37,6 +37,10 @@ static inline Array_ Array_copy(const Array_ self){
return copy; return copy;
} }
static inline void Array_free(Array_ self){
free(self.data);
}
#define Array_len(SELF, T) (SELF.size / sizeof(T)) #define Array_len(SELF, T) (SELF.size / sizeof(T))
#define Array_memset(SELF, VAL) memset(SELF.data, VAL, SELF.size) #define Array_memset(SELF, VAL) memset(SELF.data, VAL, SELF.size)

View File

@ -20,6 +20,10 @@ static inline List_ List_construct_size(void* data_ptr, u32 occupied_size, u32 a
#define List_alloc(T, INITIAL_COUNT) List_alloc_size((INITIAL_COUNT) * sizeof(T)) #define List_alloc(T, INITIAL_COUNT) List_alloc_size((INITIAL_COUNT) * sizeof(T))
List_ List_alloc_size(u32 initial_size); List_ List_alloc_size(u32 initial_size);
static inline void List_destroy(List_ self){
free(self.data);
}
List_ List_copy(List_ src); List_ List_copy(List_ src);
// alloc bigger buffer if size + size_to_add won't fit in current // alloc bigger buffer if size + size_to_add won't fit in current

View File

@ -22,7 +22,7 @@ static inline str str_from_cstr(cstr s_ptr){
return str_construct((void*)s_ptr, strlen(s_ptr), true); return str_construct((void*)s_ptr, strlen(s_ptr), true);
} }
static inline void str_destroy(str s){ static inline void str_free(str s){
free(s.data); free(s.data);
} }