Added <num>_to_str functions

This commit is contained in:
Maieul BOYER 2024-07-16 19:38:27 +02:00
parent aafd056f49
commit 698d1088e2
No known key found for this signature in database
21 changed files with 963 additions and 60 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_u8.h"
#include <stdlib.h>
@ -45,7 +42,7 @@ t_error vec_u8_push(t_vec_u8 *vec, t_u8 element)
/// Return true in case of an error
t_error vec_u8_reserve(t_vec_u8 *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_u8_reserve(t_vec_u8 *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_u8));
vec->buffer =
mem_realloc_array(vec->buffer, new_capacity, sizeof(t_u8));
vec->capacity = new_capacity;
}
return (NO_ERROR);
@ -83,6 +81,8 @@ t_error vec_u8_pop(t_vec_u8 *vec, t_u8 *value)
/// This function is safe to call with `free_elem` being NULL
void vec_u8_free(t_vec_u8 vec)
{
if (vec.buffer == NULL)
return;
if (vec.free_func)
{
while (vec.len)