Put the custom allocator in its own lib, as to lessen the difficulty to switch between libc's allocator and a custom one (#7)

This commit is contained in:
Maix0 2024-05-14 18:56:53 +02:00 committed by GitHub
parent 713f0f0302
commit cb7f3c3fdf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
85 changed files with 1121 additions and 877 deletions

View file

@ -6,11 +6,11 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/18 18:12:11 by maiboyer #+# #+# */
/* Updated: 2023/12/11 19:18:48 by maiboyer ### ########.fr */
/* Updated: 2024/05/14 18:43:13 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/mem/mem_set.h"
#include "me/mem/mem.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
#include "me/string/str_len.h"
@ -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);
me_free(start_num);
mem_free(start_num);
}

View file

@ -6,11 +6,11 @@
/* By: maix <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/18 01:44:35 by maix #+# #+# */
/* Updated: 2023/12/11 19:19:27 by maiboyer ### ########.fr */
/* Updated: 2024/05/14 18:43:24 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/mem/mem_alloc_array.h"
#include "me/mem/mem.h"
#include "me/mem/mem_set.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
@ -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);
me_free(start_num);
mem_free(start_num);
}

View file

@ -6,11 +6,11 @@
/* By: maix <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/18 01:44:35 by maix #+# #+# */
/* Updated: 2023/12/11 19:19:59 by maiboyer ### ########.fr */
/* Updated: 2024/05/14 18:43:39 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/mem/mem_alloc_array.h"
#include "me/mem/mem.h"
#include "me/mem/mem_set.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
@ -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);
me_free(start_num);
mem_free(start_num);
}

View file

@ -6,11 +6,12 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 17:57:04 by maiboyer #+# #+# */
/* Updated: 2023/12/01 21:20:07 by maiboyer ### ########.fr */
/* Updated: 2024/05/14 18:43:44 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/buffered_str/buf_str.h"
#include "me/mem/mem.h"
#include "me/convert/atoi.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/matchers/matchers.h"
@ -99,7 +100,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);
me_free(truc);
mem_free(truc);
*c_idx = *nxt + 1;
return ((t_printf_arg){
.p_args = extra.p_args,

View file

@ -6,14 +6,13 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/01 21:05:47 by maiboyer #+# #+# */
/* Updated: 2023/12/01 21:49:51 by maiboyer ### ########.fr */
/* Updated: 2024/05/14 18:43:56 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/mem/mem_alloc_array.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
#include <stdlib.h>
#include "me/mem/mem.h"
void handle_weird_precision_stuff(t_printf_arg *data, t_prec_strs strs,
t_usize value)
@ -23,7 +22,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 = (me_free(*strs.out), (t_str)mem_alloc_array(1, 1));
*strs.out = (mem_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);
me_free(str);
mem_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);
me_free(str);
mem_free(str);
return (len);
}
*/