Made a memory allocator (crude)

This commit is contained in:
Maieul BOYER 2024-05-07 15:21:41 +02:00
parent b5c7344851
commit 941bac31b6
No known key found for this signature in database
53 changed files with 469 additions and 146 deletions

View file

@ -66,5 +66,5 @@ void printf_s(t_printf_arg data, t_printf_func f)
.fill_zero = 0, .fill = 0, .len = len, .pretty = "", .pretty_len = 0, \
.str = start_num, .allow_zero_fill = false, .sign = NULL, \
.sign_len = 0, }, data, f);
free(start_num);
me_free(start_num);
}

View file

@ -85,5 +85,5 @@ void printf_d(t_printf_arg data, t_printf_func f)
.fill_zero = 0, .fill = 0, .sign = sign, .pretty = NULL, .len = \
str_len(start_num), .pretty_len = 0, .str = start_num, .allow_zero_fill \
= true, .sign_len = str_len(sign), }, data, f);
free(start_num);
me_free(start_num);
}

View file

@ -72,5 +72,5 @@ void printf_u(t_printf_arg data, t_printf_func f)
.fill_zero = 0, .fill = 0, .len = str_len(start_num), \
.pretty = NULL, .pretty_len = 0, .str = start_num, \
.allow_zero_fill = true, .sign = NULL, .sign_len = 0, }, data, f);
free(start_num);
me_free(start_num);
}

View file

@ -99,7 +99,7 @@ t_printf_arg print_substr(t_usize *c_idx, t_usize *nxt, t_const_str fmt,
truc = str_substring(fmt, *c_idx, *nxt - *c_idx);
extra.f(truc, *nxt - *c_idx, extra.p_args);
free(truc);
me_free(truc);
*c_idx = *nxt + 1;
return ((t_printf_arg){
.p_args = extra.p_args,

View file

@ -23,7 +23,7 @@ void handle_weird_precision_stuff(t_printf_arg *data, t_prec_strs strs,
data->flags &= (~ZERO_ALIGN);
data->flags |= ALIGN;
if (strs.free_out)
*strs.out = (free(*strs.out), (t_str)mem_alloc_array(1, 1));
*strs.out = (me_free(*strs.out), (t_str)mem_alloc_array(1, 1));
else
*strs.out = "";
*strs.pretty = "";

View file

@ -99,7 +99,7 @@ t_usize me_printf(t_const_str fmt, ...)
va_end(args);
len = str_len(str);
write(1, str, len);
free(str);
me_free(str);
return (len);
}
@ -114,7 +114,7 @@ t_usize me_eprintf(t_const_str fmt, ...)
va_end(args);
len = str_len(str);
write(2, str, len);
free(str);
me_free(str);
return (len);
}
*/