style: noming ast.c

This commit is contained in:
Raphael 2024-09-19 15:30:06 +02:00
parent 7243dd263d
commit b8cc83a5c0

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* ::: :::::::: */ /* ::: :::::::: */
/* vec_ast.c :+: :+: :+: */ /* ast.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/05 18:46:28 by maiboyer #+# #+# */ /* Created: 2023/12/05 18:46:28 by maiboyer #+# #+# */
/* Updated: 2023/12/09 17:54:11 by maiboyer ### ########.fr */ /* Updated: 2024/09/19 15:30:00 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,8 +15,7 @@
#include "me/vec/vec_ast.h" #include "me/vec/vec_ast.h"
#include <stdlib.h> #include <stdlib.h>
t_vec_ast vec_ast_new(t_usize capacity, t_vec_ast vec_ast_new(t_usize capacity, t_free_ast_item free_function)
t_free_ast_item free_function)
{ {
t_vec_ast out; t_vec_ast out;
@ -28,7 +27,7 @@ t_vec_ast vec_ast_new(t_usize capacity,
return (out); return (out);
} }
/// Return true in case of an error /// @return true in case of an error
t_error vec_ast_push(t_vec_ast *vec, t_ast_node element) t_error vec_ast_push(t_vec_ast *vec, t_ast_node element)
{ {
if (vec == NULL) if (vec == NULL)
@ -51,8 +50,8 @@ t_error vec_ast_reserve(t_vec_ast *vec, t_usize wanted_capacity)
new_capacity = (vec->capacity * 3) / 2 + 1; new_capacity = (vec->capacity * 3) / 2 + 1;
while (wanted_capacity > new_capacity) while (wanted_capacity > new_capacity)
new_capacity = (new_capacity * 3) / 2 + 1; new_capacity = (new_capacity * 3) / 2 + 1;
vec->buffer = vec->buffer = mem_realloc_array(\
mem_realloc_array(vec->buffer, new_capacity, sizeof(t_ast_node)); vec->buffer, new_capacity, sizeof(t_ast_node));
vec->capacity = new_capacity; vec->capacity = new_capacity;
} }
return (NO_ERROR); return (NO_ERROR);
@ -80,7 +79,7 @@ t_error vec_ast_pop(t_vec_ast *vec, t_ast_node *value)
void vec_ast_free(t_vec_ast vec) void vec_ast_free(t_vec_ast vec)
{ {
if (vec.buffer == NULL) if (vec.buffer == NULL)
return; return ;
if (vec.free_func) if (vec.free_func)
{ {
while (vec.len) while (vec.len)