Compiling!

This commit is contained in:
Maieul BOYER 2024-04-30 14:20:06 +02:00
parent 019d25174c
commit a22b9ea234
No known key found for this signature in database
24 changed files with 607 additions and 113 deletions

View file

@ -53,5 +53,6 @@ void vec_C__PREFIX___iter(t_vec_C__PREFIX__ *vec,
void vec_C__PREFIX___reverse(t_vec_C__PREFIX__ *vec);
void vec_C__PREFIX___sort(t_vec_C__PREFIX__ *vec,
t_vec_C__PREFIX___sort_fn is_sorted);
t_error vec_C__PREFIX___back(t_vec_C__PREFIX__ *vec, C__TYPENAME__ **out);
#endif

View file

@ -71,3 +71,14 @@ void vec_C__PREFIX___reverse(t_vec_C__PREFIX__ *vec)
i++;
}
}
t_error vec_C__PREFIX___back(t_vec_C__PREFIX__ *vec, C__TYPENAME__ **out)
{
C__TYPENAME__ *temporary;
if (out == NULL)
out = &temporary;
if (vec->len != 0)
return (*out = &vec->buffer[vec->len - 1], true);
return (false);
}

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 17:54:28 by maiboyer #+# #+# */
/* Updated: 2023/12/31 15:34:29 by maiboyer ### ########.fr */
/* Updated: 2024/04/30 14:14:42 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,6 +25,7 @@ bool push_str_buffer(t_buffer_str *buf, t_const_str to_push);
bool push_str_char(t_buffer_str *buf, char to_push);
void str_clear(t_buffer_str *buf);
t_buffer_str alloc_new_buffer(t_usize capacity);
t_error str_reserve(t_buffer_str *buf, t_usize size);
static inline void str_free(t_buffer_str buf)
{

View file

@ -53,5 +53,6 @@ void vec_buf_str_iter(t_vec_buf_str *vec,
void vec_buf_str_reverse(t_vec_buf_str *vec);
void vec_buf_str_sort(t_vec_buf_str *vec,
t_vec_buf_str_sort_fn is_sorted);
t_error vec_buf_str_back(t_vec_buf_str *vec, t_buffer_str **out);
#endif

View file

@ -53,5 +53,6 @@ void vec_str_iter(t_vec_str *vec,
void vec_str_reverse(t_vec_str *vec);
void vec_str_sort(t_vec_str *vec,
t_vec_str_sort_fn is_sorted);
t_error vec_str_back(t_vec_str *vec, t_str **out);
#endif

View file

@ -53,5 +53,6 @@ void vec_u8_iter(t_vec_u8 *vec,
void vec_u8_reverse(t_vec_u8 *vec);
void vec_u8_sort(t_vec_u8 *vec,
t_vec_u8_sort_fn is_sorted);
t_error vec_u8_back(t_vec_u8 *vec, t_u8 **out);
#endif

View file

@ -71,3 +71,14 @@ void vec_buf_str_reverse(t_vec_buf_str *vec)
i++;
}
}
t_error vec_buf_str_back(t_vec_buf_str *vec, t_buffer_str **out)
{
t_buffer_str *temporary;
if (out == NULL)
out = &temporary;
if (vec->len != 0)
return (*out = &vec->buffer[vec->len - 1], true);
return (false);
}

View file

@ -71,3 +71,14 @@ void vec_str_reverse(t_vec_str *vec)
i++;
}
}
t_error vec_str_back(t_vec_str *vec, t_str **out)
{
t_str *temporary;
if (out == NULL)
out = &temporary;
if (vec->len != 0)
return (*out = &vec->buffer[vec->len - 1], true);
return (false);
}

View file

@ -71,3 +71,14 @@ void vec_u8_reverse(t_vec_u8 *vec)
i++;
}
}
t_error vec_u8_back(t_vec_u8 *vec, t_u8 **out)
{
t_u8 *temporary;
if (out == NULL)
out = &temporary;
if (vec->len != 0)
return (*out = &vec->buffer[vec->len - 1], true);
return (false);
}

View file

@ -16,6 +16,7 @@ blx/sprite/get_pixel
blx/sprite/new_image
blx/sprite/sprite_draw_onto_sprite
buffered_str/mod
buffered_str/push_char
char/isalnum
char/isalpha
char/isascii

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 17:52:12 by maiboyer #+# #+# */
/* Updated: 2024/04/28 20:05:41 by maiboyer ### ########.fr */
/* Updated: 2024/04/30 14:14:03 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,11 +19,32 @@
#include "me/types.h"
#include <stdlib.h>
bool push_str_buffer(t_buffer_str *buf, t_const_str to_push)
t_error str_reserve(t_buffer_str *buf, t_usize size)
{
t_usize to_push_len;
t_str temp_buffer;
t_usize new_capacity;
t_usize new_capacity;
if (buf == NULL)
return (ERROR);
while (size > buf->capacity)
{
new_capacity = (buf->capacity * 3) / 2 + 1;
temp_buffer = mem_alloc(new_capacity);
if (temp_buffer == NULL)
return (true);
str_l_copy(temp_buffer, buf->buf, new_capacity);
free(buf->buf);
buf->buf = temp_buffer;
buf->capacity = new_capacity;
}
return (NO_ERROR);
}
bool push_str_buffer(t_buffer_str *buf, t_const_str to_push)
{
t_usize to_push_len;
t_str temp_buffer;
t_usize new_capacity;
if (buf == NULL || to_push == NULL)
return (true);
@ -44,26 +65,26 @@ bool push_str_buffer(t_buffer_str *buf, t_const_str to_push)
return (false);
}
bool push_str_char(t_buffer_str *buf, char to_push)
bool push_str_char(t_buffer_str *buf, char to_push)
{
char push_str[2];
char push_str[2];
push_str[0] = to_push;
push_str[1] = 0;
return (push_str_buffer(buf, push_str));
}
void str_clear(t_buffer_str *buf)
void str_clear(t_buffer_str *buf)
{
mem_set_zero(buf->buf, buf->capacity);
buf->len = 0;
return ;
return;
}
t_buffer_str alloc_new_buffer(t_usize capacity)
t_buffer_str alloc_new_buffer(t_usize capacity)
{
t_buffer_str out;
t_str buf;
t_buffer_str out;
t_str buf;
if (capacity == 0)
capacity = 16;

View file

@ -0,0 +1,13 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push_char.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/30 14:17:47 by maiboyer #+# #+# */
/* Updated: 2024/04/30 14:17:47 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */