removed elements freeing in autoarr
This commit is contained in:
parent
5ddc96e1b4
commit
b6088845d9
@ -1,17 +1,17 @@
|
|||||||
#include "Autoarr.h"
|
#include "Autoarr.h"
|
||||||
|
|
||||||
Autoarr_define(Pointer, true)
|
Autoarr_define(Pointer)
|
||||||
Autoarr_define(char, false)
|
Autoarr_define(char)
|
||||||
Autoarr_define(bool, false)
|
Autoarr_define(bool)
|
||||||
Autoarr_define(f32, false)
|
Autoarr_define(f32)
|
||||||
Autoarr_define(f64, false)
|
Autoarr_define(f64)
|
||||||
Autoarr_define(u8, false)
|
Autoarr_define(u8)
|
||||||
Autoarr_define(i8, false)
|
Autoarr_define(i8)
|
||||||
Autoarr_define(u16, false)
|
Autoarr_define(u16)
|
||||||
Autoarr_define(i16, false)
|
Autoarr_define(i16)
|
||||||
Autoarr_define(u32, false)
|
Autoarr_define(u32)
|
||||||
Autoarr_define(i32, false)
|
Autoarr_define(i32)
|
||||||
Autoarr_define(u64, false)
|
Autoarr_define(u64)
|
||||||
Autoarr_define(i64, false)
|
Autoarr_define(i64)
|
||||||
|
|
||||||
Autoarr_define(Unitype, false)
|
Autoarr_define(Unitype)
|
||||||
|
|||||||
@ -6,7 +6,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "../base/base.h"
|
#include "../base/base.h"
|
||||||
|
|
||||||
#define Autoarr_define(TYPE, TYPE_IS_PTR) \
|
#define Autoarr_define(TYPE) \
|
||||||
\
|
\
|
||||||
void __Autoarr_##TYPE##_add(Autoarr_##TYPE* ar, TYPE element){ \
|
void __Autoarr_##TYPE##_add(Autoarr_##TYPE* ar, TYPE element){ \
|
||||||
TYPE* ptr = allocator_alloc(InternalAllocator_getPtr(ar), sizeof(element)); \
|
TYPE* ptr = allocator_alloc(InternalAllocator_getPtr(ar), sizeof(element)); \
|
||||||
@ -42,13 +42,6 @@ void __Autoarr_##TYPE##_set(Autoarr_##TYPE* ar, u32 index, TYPE value){ \
|
|||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void __Autoarr_##TYPE##_destruct(Autoarr_##TYPE* ar){ \
|
void __Autoarr_##TYPE##_destruct(Autoarr_##TYPE* ar){ \
|
||||||
destruct_t value_destructor=ar->type->destruct; \
|
|
||||||
if(value_destructor!=NULL) { \
|
|
||||||
Autoarr_foreach(ar, el, \
|
|
||||||
TYPE* value_ptr = TYPE_IS_PTR ? *(TYPE**)(&el) : ⪙ \
|
|
||||||
value_destructor(value_ptr); \
|
|
||||||
); \
|
|
||||||
} \
|
|
||||||
InternalAllocator_destructIfInternal(LinearAllocator, ar); \
|
InternalAllocator_destructIfInternal(LinearAllocator, ar); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
@ -74,7 +67,7 @@ __Autoarr_##TYPE##_functions_list_t __Autoarr_##TYPE##_functions_list={ \
|
|||||||
void __Autoarr_##TYPE##_construct(Autoarr_##TYPE* ar, alloc_size_t starting_size, allocator_ptr data_allocator){ \
|
void __Autoarr_##TYPE##_construct(Autoarr_##TYPE* ar, alloc_size_t starting_size, allocator_ptr data_allocator){ \
|
||||||
InternalAllocator_setExternalOrConstruct(ar, data_allocator, LinearAllocator, starting_size); \
|
InternalAllocator_setExternalOrConstruct(ar, data_allocator, LinearAllocator, starting_size); \
|
||||||
ar->functions=&__Autoarr_##TYPE##_functions_list; \
|
ar->functions=&__Autoarr_##TYPE##_functions_list; \
|
||||||
ar->type = TYPE_IS_PTR ? &ktDescriptor_namePtr(TYPE) : &ktDescriptor_name(TYPE); \
|
ar->type = &ktDescriptor_name(TYPE); \
|
||||||
ar->length=0; \
|
ar->length=0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
kt_define(string, NULL, NULL);
|
kt_define(string, NULL, NULL);
|
||||||
Autoarr_define(string, false);
|
Autoarr_define(string);
|
||||||
|
|
||||||
// copies str content to new char pointer value (adding '\0' at the end)
|
// copies str content to new char pointer value (adding '\0' at the end)
|
||||||
char* string_extract(allocator_ptr al, string str){
|
char* string_extract(allocator_ptr al, string str){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user