Use asserts in array
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
assert(allocator != NULL);
|
||||
|
||||
u64 allocation_size = sizeof({ArrayType}) + item_size * capacity;
|
||||
{ArrayType} *array = NULL;
|
||||
|
||||
if (!allocator) {{
|
||||
goto RETURN_GENERIC_ARRAY_ALLOC;
|
||||
}}
|
||||
|
||||
array = wapp_mem_allocator_alloc(allocator, allocation_size);
|
||||
{ArrayType} *array = wapp_mem_allocator_alloc(allocator, allocation_size);
|
||||
if (!array) {{
|
||||
goto RETURN_GENERIC_ARRAY_ALLOC;
|
||||
}}
|
||||
|
@@ -1,8 +1,6 @@
|
||||
{ArrayType} *output = array;
|
||||
assert(allocator != NULL && array != NULL);
|
||||
|
||||
if (!allocator || !array) {{
|
||||
goto RETURN_{Tupper}_ARRAY_APPEND_ALLOC;
|
||||
}}
|
||||
{ArrayType} *output = array;
|
||||
|
||||
if (array->count >= array->capacity) {{
|
||||
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2);
|
||||
|
@@ -1,6 +1,4 @@
|
||||
if (!array || array->count >= array->capacity) {{
|
||||
return;
|
||||
}}
|
||||
assert(array != NULL && array->count < array->capacity);
|
||||
|
||||
u64 index = (array->count)++;
|
||||
wapp_{Tlower}_array_set(array, index, item);
|
||||
|
@@ -1,6 +1,4 @@
|
||||
if (!array || index >= array->count) {{
|
||||
return NULL;
|
||||
}}
|
||||
assert(array != NULL & index < array->count);
|
||||
|
||||
u8 *ptr = (u8 *)(array->items) + (array->item_size * index);
|
||||
return ({T} *)ptr;
|
||||
|
@@ -1,6 +1,3 @@
|
||||
{T} *ptr = wapp_{Tlower}_array_get(array, index);
|
||||
if (!ptr) {{
|
||||
return;
|
||||
}}
|
||||
|
||||
memcpy((void *)ptr, (void *)item, array->item_size);
|
||||
|
@@ -1,5 +1,2 @@
|
||||
if (!array) {{
|
||||
return;
|
||||
}}
|
||||
|
||||
assert(array != NULL);
|
||||
array->count = 0;
|
||||
|
@@ -1,8 +1,6 @@
|
||||
{ArrayType} *output = dst;
|
||||
assert(allocator != NULL & src != NULL && dst != NULL);
|
||||
|
||||
if (!allocator || !src || !dst) {{
|
||||
goto RETURN_{Tupper}_ARRAY_COPY_ALLOC;
|
||||
}}
|
||||
{ArrayType} *output = dst;
|
||||
|
||||
if (src->count >= dst->capacity) {{
|
||||
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(dst->capacity * 2);
|
||||
|
@@ -1,6 +1,4 @@
|
||||
if (!src || !dst) {{
|
||||
return;
|
||||
}}
|
||||
assert(src != NULL && dst != NULL);
|
||||
|
||||
wapp_{Tlower}_array_clear(dst);
|
||||
|
||||
|
@@ -1,8 +1,6 @@
|
||||
{ArrayType} *output = array;
|
||||
assert(allocator != NULL && array != NULL && other != NULL);
|
||||
|
||||
if (!allocator || !array || !other) {{
|
||||
goto RETURN_{Tupper}_ARRAY_EXTEND_ALLOC;
|
||||
}}
|
||||
{ArrayType} *output = array;
|
||||
|
||||
u64 remaining_capacity = array->capacity - array->count;
|
||||
if (other->count >= remaining_capacity) {{
|
||||
|
@@ -1,11 +1,7 @@
|
||||
if (!array || !other) {{
|
||||
return;
|
||||
}}
|
||||
assert(array != NULL && other != NULL);
|
||||
|
||||
u64 remaining_capacity = array->capacity - array->count;
|
||||
if (other->count >= remaining_capacity) {{
|
||||
return;
|
||||
}}
|
||||
assert(other->count < remaining_capacity);
|
||||
|
||||
{T} *item;
|
||||
|
||||
|
Reference in New Issue
Block a user