added check for zero size in Array_alloc

This commit is contained in:
Timerix 2025-11-13 00:37:59 +05:00
parent 3034e4d186
commit 77589878c1

View File

@ -17,7 +17,7 @@ typedef struct Array_ {
#define Array_alloc(T, COUNT) Array_alloc_size((COUNT) * sizeof(T))
static inline Array_ Array_alloc_size(u32 size){
return Array_construct_size(malloc(size), size);
return Array_construct_size(size > 0 ? malloc(size) : NULL, size);
}
#define Array_realloc(SELF, T, COUNT) Array_realloc_size(SELF, (COUNT) * sizeof(T))