normed: output directory

This commit is contained in:
maix0 2024-10-12 15:45:45 +02:00
parent 7bb95e24a6
commit 3d11b63428
37 changed files with 692 additions and 708 deletions

View file

@ -15,10 +15,9 @@
#include "me/vec/vec_str.h"
#include <stdlib.h>
t_vec_str vec_str_new(t_usize capacity,
t_free_str_item free_function)
t_vec_str vec_str_new(t_usize capacity, t_free_str_item free_function)
{
t_vec_str out;
t_vec_str out;
out = (t_vec_str){0};
out.free_func = free_function;
@ -29,7 +28,7 @@ t_vec_str vec_str_new(t_usize capacity,
}
/// Return true in case of an error
t_error vec_str_push(t_vec_str *vec, t_str element)
t_error vec_str_push(t_vec_str *vec, t_str element)
{
if (vec == NULL)
return (ERROR);
@ -40,9 +39,9 @@ t_error vec_str_push(t_vec_str *vec, t_str element)
}
/// Return true in case of an error
t_error vec_str_reserve(t_vec_str *vec, t_usize wanted_capacity)
t_error vec_str_reserve(t_vec_str *vec, t_usize wanted_capacity)
{
size_t new_capacity;
size_t new_capacity;
if (vec == NULL)
return (ERROR);
@ -51,8 +50,8 @@ t_error vec_str_reserve(t_vec_str *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_str));
vec->buffer = mem_realloc_array(vec->buffer, new_capacity,
sizeof(t_str));
vec->capacity = new_capacity;
}
return (NO_ERROR);
@ -60,10 +59,10 @@ t_error vec_str_reserve(t_vec_str *vec, t_usize wanted_capacity)
/// Return true if the vector is empty
/// This function is safe to call with value being NULL
t_error vec_str_pop(t_vec_str *vec, t_str *value)
t_error vec_str_pop(t_vec_str *vec, t_str *value)
{
t_str temp_value;
t_str *ptr;
t_str temp_value;
t_str *ptr;
if (vec == NULL || vec->len == 0)
return (ERROR);
@ -77,10 +76,10 @@ t_error vec_str_pop(t_vec_str *vec, t_str *value)
}
/// This function is safe to call with `free_elem` being NULL
void vec_str_free(t_vec_str vec)
void vec_str_free(t_vec_str vec)
{
if (vec.buffer == NULL)
return;
return ;
if (vec.free_func)
{
while (vec.len)