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,7 +15,7 @@
#include "me/vec/vec_str.h"
#include <stdlib.h>
t_str *vec_str_get(t_vec_str *vec, t_usize i)
t_str *vec_str_get(t_vec_str *vec, t_usize i)
{
if (vec == NULL || vec->buffer == NULL)
return (NULL);
@ -24,14 +24,14 @@ t_str *vec_str_get(t_vec_str *vec, t_usize i)
return (NULL);
}
t_str *vec_str_last(t_vec_str *vec)
t_str *vec_str_last(t_vec_str *vec)
{
if (vec == NULL || vec->len == 0)
return (NULL);
return (&vec->buffer[vec->len - 1]);
}
void vec_str_copy_into(t_vec_str *vec, t_vec_str *dest)
void vec_str_copy_into(t_vec_str *vec, t_vec_str *dest)
{
if (vec == NULL || dest == NULL)
return ;
@ -39,21 +39,19 @@ void vec_str_copy_into(t_vec_str *vec, t_vec_str *dest)
mem_copy(dest->buffer, vec->buffer, vec->len * sizeof(t_str));
}
struct s_vec_str_splice_arguments vec_str_splice_args(
t_usize index, t_usize old_count, t_usize new_count,
const t_str *elements)
struct s_vec_str_splice_arguments vec_str_splice_args(t_usize index,
t_usize old_count, t_usize new_count, const t_str *elements)
{
return ((struct s_vec_str_splice_arguments){index, old_count,
new_count, elements});
return ((struct s_vec_str_splice_arguments){index, old_count, new_count,
elements});
}
void vec_str_splice(t_vec_str *self,
struct s_vec_str_splice_arguments args)
void vec_str_splice(t_vec_str *self, struct s_vec_str_splice_arguments args)
{
t_str *contents;
t_u32 new_size;
t_u32 old_end;
t_u32 new_end;
t_str *contents;
t_u32 new_size;
t_u32 old_end;
t_u32 new_end;
new_size = self->len + args.new_count - args.old_count;
old_end = args.index + args.old_count;
@ -61,17 +59,16 @@ void vec_str_splice(t_vec_str *self,
vec_str_reserve(self, new_size);
contents = self->buffer;
if (self->len > old_end)
mem_move(contents + new_end,
contents + old_end,
(self->len - old_end) * sizeof(t_str));
mem_move(contents + new_end, contents + old_end, (self->len - old_end)
* sizeof(t_str));
if (args.new_count > 0)
{
if (args.elements)
mem_copy((contents + args.index * sizeof(t_str)),
args.elements, args.new_count * sizeof(t_str));
mem_copy((contents + args.index * sizeof(t_str)), args.elements,
args.new_count * sizeof(t_str));
else
mem_set_zero((contents + args.index * sizeof(t_str)),
args.new_count * sizeof(t_str));
mem_set_zero((contents + args.index * sizeof(t_str)), args.new_count
* sizeof(t_str));
}
self->len += args.new_count - args.old_count;
}