style: noming ast_function(3/4).c

This commit is contained in:
Raphael 2024-09-19 15:36:59 +02:00
parent 70519085be
commit efac395168
2 changed files with 31 additions and 33 deletions

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_ast.c :+: :+: :+: */
/* ast_functions3.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
/* Updated: 2024/09/19 15:34:10 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,15 +15,14 @@
#include "me/vec/vec_ast.h"
#include <stdlib.h>
t_error vec_ast_push_front(t_vec_ast *vec,
t_ast_node element)
t_error vec_ast_push_front(t_vec_ast *vec, t_ast_node element)
{
t_usize i;
if (vec->len == 0)
return (vec_ast_push(vec, element));
i = vec->len - 1;
if (vec->capacity < vec->len + 1 &&
if (vec->capacity < vec->len + 1 && \
vec_ast_reserve(vec, 3 * vec->len / 2 + 1))
return (ERROR);
while (i > 0)

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_ast.c :+: :+: :+: */
/* ast_functions4.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
/* Updated: 2024/09/19 15:36:47 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -43,12 +43,11 @@ struct s_vec_ast_splice_arguments vec_ast_splice_args(
t_usize index, t_usize old_count, t_usize new_count,
const t_ast_node *elements)
{
return ((struct s_vec_ast_splice_arguments){index, old_count,
return ((struct s_vec_ast_splice_arguments){index, old_count, \
new_count, elements});
}
void vec_ast_splice(t_vec_ast *self,
struct s_vec_ast_splice_arguments args)
void vec_ast_splice(t_vec_ast *self, struct s_vec_ast_splice_arguments args)
{
t_ast_node *contents;
t_u32 new_size;
@ -61,13 +60,13 @@ void vec_ast_splice(t_vec_ast *self,
vec_ast_reserve(self, new_size);
contents = self->buffer;
if (self->len > old_end)
mem_move(contents + new_end,
contents + old_end,
mem_move(contents + new_end, \
contents + old_end, \
(self->len - old_end) * sizeof(t_ast_node));
if (args.new_count > 0)
{
if (args.elements)
mem_copy((contents + args.index * sizeof(t_ast_node)),
mem_copy((contents + args.index * sizeof(t_ast_node)), \
args.elements, args.new_count * sizeof(t_ast_node));
else
mem_set_zero((contents + args.index * sizeof(t_ast_node)),