feat: base + display functions!!!!!

This commit is contained in:
mcolonna 2024-02-26 14:18:51 +01:00
parent ebb5931632
commit 664b18eb2e
187 changed files with 29451 additions and 0 deletions

42
libtf/include/mem_utils.h Normal file
View file

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_utils.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/18 16:37:23 by mcolonna #+# #+# */
/* Updated: 2024/01/23 18:13:29 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_UTILS_H
# define MEM_UTILS_H
# include "libtf.h"
# include "mem_utils.h"
# include <stdlib.h>
typedef struct s_memclass_in *t_memclass_in;
typedef struct s_element t_element;
typedef struct s_element
{
void *address;
t_element *previous;
t_element *next;
t_memclass_in mc;
} t_element;
typedef struct s_memclass_in
{
t_element *first;
} *t_memclass_in;
void *create_address_with_element(t_element *element, size_t size);
t_element *get_address_element(void *address);
void free_address_with_element(void *address);
#endif

View file

@ -0,0 +1,61 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* read_line_utils.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/30 15:36:49 by mcolonna #+# #+# */
/* Updated: 2024/02/23 14:17:46 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef READ_LINE_UTILS_H
# define READ_LINE_UTILS_H
# include "libtf.h"
# ifndef BUFFER_SIZE
# define BUFFER_SIZE 1000
# endif
# define NB_FILE_DESCRIPTORS 4096
typedef struct s_buf
{
int size;
char str[BUFFER_SIZE];
} t_buf;
typedef struct s_string2
{
int size;
char *str;
} t_string2;
typedef struct s_errmc
{
t_err *err;
t_memclass mc;
} t_errmc;
// NULL if error.
// Return a pointer to free. Nothing if error.
int create_empty_buf(t_buf **result);
// -1 if error, or else 1.
// string->str will be freed, the new string->str will be to free.
// If error, no free or malloc is done.
int append_to_string(
t_string2 *string, char *to_append, int to_append_size);
// Return 0 if error, or else 1.
// *result (and its "str" value) to free. Nothing to free if error.
int create_empty_string(t_string2 **result);
// Free string->str and string.
void free_string(t_string2 **string);
t_errmc setget_errmc(t_err err, t_memclass mc);
#endif

22
libtf/include/str_utils.h Normal file
View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_utils.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/09 17:13:15 by mcolonna #+# #+# */
/* Updated: 2024/02/09 17:13:39 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_UTILS_H
# define STR_UTILS_H
typedef struct s_two_strings
{
t_const_string str;
t_const_string charset;
} t_two_strings;
#endif