Normed most of the stdme
This commit is contained in:
parent
882d5cb5bb
commit
ac5458d42c
31 changed files with 149 additions and 617 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/16 17:52:12 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/18 18:06:37 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 18:02:36 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,10 +19,10 @@
|
|||
#include "me/types.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
t_error str_reserve(t_string *buf, t_usize size)
|
||||
t_error str_reserve(t_string *buf, t_usize size)
|
||||
{
|
||||
t_str temp_buffer;
|
||||
t_usize new_capacity;
|
||||
t_usize new_capacity;
|
||||
|
||||
if (buf == NULL)
|
||||
return (ERROR);
|
||||
|
|
@ -42,9 +42,9 @@ t_error str_reserve(t_string *buf, t_usize size)
|
|||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_error string_push(t_string *buf, t_const_str to_push)
|
||||
t_error string_push(t_string *buf, t_const_str to_push)
|
||||
{
|
||||
t_usize to_push_len;
|
||||
t_usize to_push_len;
|
||||
|
||||
if (buf == NULL || to_push == NULL)
|
||||
return (ERROR);
|
||||
|
|
@ -56,26 +56,26 @@ t_error string_push(t_string *buf, t_const_str to_push)
|
|||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
bool string_push_char(t_string *buf, char to_push)
|
||||
bool string_push_char(t_string *buf, char to_push)
|
||||
{
|
||||
char push_str[2];
|
||||
char push_str[2];
|
||||
|
||||
push_str[0] = to_push;
|
||||
push_str[1] = 0;
|
||||
return (string_push(buf, push_str));
|
||||
}
|
||||
|
||||
void string_clear(t_string *buf)
|
||||
void string_clear(t_string *buf)
|
||||
{
|
||||
mem_set_zero(buf->buf, buf->capacity);
|
||||
buf->len = 0;
|
||||
return;
|
||||
return ;
|
||||
}
|
||||
|
||||
t_string string_new(t_usize capacity)
|
||||
t_string string_new(t_usize capacity)
|
||||
{
|
||||
t_string out;
|
||||
t_str buf;
|
||||
t_string out;
|
||||
t_str buf;
|
||||
|
||||
if (capacity == 0)
|
||||
capacity = 16;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/08 21:32:17 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/08 22:25:52 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 18:01:27 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,9 +15,10 @@
|
|||
#include "me/string/string.h"
|
||||
#include "me/types.h"
|
||||
|
||||
t_error string_insert(t_string *self, t_usize pos, t_str str)
|
||||
t_error string_insert(t_string *self, t_usize pos, t_str str)
|
||||
{
|
||||
t_usize len;
|
||||
t_usize len;
|
||||
|
||||
if (self == NULL || str == NULL || pos > self->len)
|
||||
return (ERROR);
|
||||
if (pos == self->len)
|
||||
|
|
@ -32,9 +33,9 @@ t_error string_insert(t_string *self, t_usize pos, t_str str)
|
|||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_error string_insert_char(t_string *self, t_usize pos, char chr)
|
||||
t_error string_insert_char(t_string *self, t_usize pos, char chr)
|
||||
{
|
||||
char tmp[2];
|
||||
char tmp[2];
|
||||
|
||||
if (chr == '\0')
|
||||
return (ERROR);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/08 21:50:27 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/08 21:54:45 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 18:01:53 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,9 +15,9 @@
|
|||
#include "me/string/string.h"
|
||||
#include "me/types.h"
|
||||
|
||||
t_error string_remove(t_string *self, t_usize pos, char *out)
|
||||
t_error string_remove(t_string *self, t_usize pos, char *out)
|
||||
{
|
||||
char fake_out;
|
||||
char fake_out;
|
||||
|
||||
if (out == NULL)
|
||||
out = &fake_out;
|
||||
|
|
@ -30,7 +30,7 @@ t_error string_remove(t_string *self, t_usize pos, char *out)
|
|||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_error string_clear_after(t_string *self, t_usize pos)
|
||||
t_error string_clear_after(t_string *self, t_usize pos)
|
||||
{
|
||||
if (self == NULL || pos >= self->len)
|
||||
return (ERROR);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/08 22:02:49 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/08 22:04:49 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 18:01:40 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
#include "me/string/string.h"
|
||||
#include "me/types.h"
|
||||
|
||||
t_error string_reserve(t_string *self, t_usize capacity)
|
||||
t_error string_reserve(t_string *self, t_usize capacity)
|
||||
{
|
||||
if (self == NULL)
|
||||
return (ERROR);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue