Updated to fix fucking dumb bug

This commit is contained in:
Maix0 2024-06-28 19:42:21 +02:00
parent efec224b6a
commit 14647f3671
7 changed files with 45 additions and 38 deletions

View file

@ -10,11 +10,8 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/mem/mem.h"
#include "me/vec/vec_ast.h"
#include <stdlib.h>
@ -45,7 +42,7 @@ t_error vec_ast_push(t_vec_ast *vec, t_ast_node element)
/// Return true in case of an error
t_error vec_ast_reserve(t_vec_ast *vec, t_usize wanted_capacity)
{
size_t new_capacity;
size_t new_capacity;
if (vec == NULL)
return (ERROR);
@ -54,7 +51,8 @@ t_error vec_ast_reserve(t_vec_ast *vec, t_usize wanted_capacity)
new_capacity = (vec->capacity * 3) / 2 + 1;
while (wanted_capacity > new_capacity)
new_capacity = (new_capacity * 3) / 2 + 1;
vec->buffer = mem_realloc_array(vec->buffer, new_capacity, sizeof(t_ast_node));
vec->buffer =
mem_realloc_array(vec->buffer, new_capacity, sizeof(t_ast_node));
vec->capacity = new_capacity;
}
return (NO_ERROR);
@ -83,6 +81,8 @@ t_error vec_ast_pop(t_vec_ast *vec, t_ast_node *value)
/// This function is safe to call with `free_elem` being NULL
void vec_ast_free(t_vec_ast vec)
{
if (vec.buffer == NULL)
return;
if (vec.free_func)
{
while (vec.len)