update stuff

This commit is contained in:
Maix0 2024-05-20 00:35:39 +02:00
parent 5973022688
commit 544ed8b045
194 changed files with 2060 additions and 1464 deletions

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/14 18:32:57 by maiboyer #+# #+# */
/* Updated: 2024/05/14 18:39:13 by maiboyer ### ########.fr */
/* Updated: 2024/05/19 17:04:44 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,11 +14,87 @@
#define MEM_H
#include "me/types.h"
/// @brief Allocate [size] bytes of memory
/// @param size number of bytes to allocate
/// @return a pointer of at least [size] bytes
/// @remark will abort if unable to allocate
void *mem_alloc(t_usize size);
/// @brief Allocate [size] * [count] bytes of memory
/// @param size number of elements
/// @param count number of bytes of each element
/// @return a pointer of at least [size] * [count] bytes
/// @remark will abort if unable to allocate, or if the multiplication overflows
void *mem_alloc_array(t_usize size, t_usize count);
/// @brief Extend or Reallocate [size] bytes
/// @param ptr pointer to the memory block
/// @param size number of bytes required
/// @return a pointer of at least [size] bytes, it may be the same pointer as [ptr] if it was able to be extended
/// @remark will abort if unable to allocate
/// @remark Will be equal to an `mem_alloc` if [ptr] == NULL
void *mem_realloc(void *ptr, t_usize size);
/// @brief Extend or Reallocate [size] * [count] bytes
/// @param ptr pointer to the memory block
/// @param size size of each element in bytes
/// @param count number of elements
/// @return a pointer of at least [size] * [count] bytes, it may be the same pointer as [ptr] if it was able to be extended
/// @remark will abort if unable to allocate
/// @remark Will be equal to an `mem_alloc_array` if [ptr] == NULL
void *mem_realloc_array(void *ptr, t_usize size, t_usize count);
void mem_free(void *ptr);
/// @brief Set the memory block assigned at [ptr] as unsued
/// @param ptr the memory block to free
void mem_free(void *ptr);
/// @brief Set [count] bytes to zero at the pointer [buf]
/// @param buf start of at least [count] bytes
/// @param count number of bytes to set to zero
void mem_set_zero(void *buf, t_usize count);
/// @brief Set [count] bytes to [byte] at the pointer [buf]
/// @param buf start of at least [count] bytes
/// @param byte byte to set
/// @param count number of bytes to set to [byte]
void mem_set(void *buf, t_u8 byte, t_usize count);
/// @brief Copy [count] bytes from [source] to [destination]
/// @param destination pointer to at least [count] bytes
/// @param source pointer to at least [count] bytes
/// @param count number of bytes to copy
/// @return [destination]
void *mem_move(void *destination, const void *source, t_usize count);
/// @brief Copy [count] bytes from [source] to [destination]
/// @param destination pointer to at least [count] bytes
/// @param source pointer to at least [count] bytes
/// @param count number of bytes to copy
/// @return [destination]
void *mem_copy(void *destination, const void *source, t_usize count);
/// @brief find a byte [find] in the buffer [buf] of size [count]
/// @param buf the buffer to search in
/// @param find the byte to find
/// @param count the number of bytes to search
/// @return the pointer to the first occurence of [find] or NULL if not found
void *mem_find(void *buf, t_u8 find, t_usize count);
/// @brief find bytes [find][.find_count] in the buffer [buf] of size [count]
/// @param buf the buffer to search in
/// @param find pointer to the bytes to find
/// @param find_count number of the bytes to find
/// @param count the number of bytes to search
/// @return the pointer to the first occurence of [find] or NULL if not found
void *mem_find_bytes(void *buf, t_u8 *find, t_usize find_count, t_usize count);
/// @brief compare [count] bytes from [lhs] to [rhs]
/// @param lhs bytes to compare
/// @param rhs bytes to compare
/// @param count number of bytes to compare
/// @return true if the bytes are equal for [count] bytes, false otherwise
bool mem_compare(const void *lhs, const void *rhs, t_usize count);
#endif /* MEM_H */

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_alloc.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/06 14:47:49 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:41:31 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_ALLOC_H
# define MEM_ALLOC_H
# include "me/types.h"
void *mem_alloc(t_usize size);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_alloc_array.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 15:53:21 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:19:45 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_ALLOC_ARRAY_H
# define MEM_ALLOC_ARRAY_H
# include "me/types.h"
void *mem_alloc_array(t_usize item_count, t_usize item_size);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_compare.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:21:14 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_COMPARE_H
# define MEM_COMPARE_H
# include "me/types.h"
t_i32 mem_compare(const void *lhs, const void *rhs, t_usize count);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_copy.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:21:31 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_COPY_H
# define MEM_COPY_H
# include "me/types.h"
void *mem_copy(void *destination, const void *source, t_usize count);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_find.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:24:03 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_FIND_H
# define MEM_FIND_H
# include "me/types.h"
void *mem_find(void *buf, t_u8 find, t_usize count);
#endif

View file

@ -1,21 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_find_bytes.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2024/01/06 18:24:04 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_FIND_BYTES_H
# define MEM_FIND_BYTES_H
# include "me/types.h"
void *mem_find_bytes(void *buf, t_u8 *find, t_usize find_count,
t_usize count);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_move.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:24:26 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_MOVE_H
# define MEM_MOVE_H
# include "me/types.h"
void *mem_move(void *destination, const void *source, t_usize count);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_realloc.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/07 12:47:23 by maiboyer #+# #+# */
/* Updated: 2024/05/07 12:47:42 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_REALLOC_H
#define MEM_REALLOC_H
#include "me/types.h"
void *mem_realloc(void *ptr, t_usize size);
#endif /* MEM_REALLOC_H */

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_set.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:25:19 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_SET_H
# define MEM_SET_H
# include "me/types.h"
void mem_set(void *buf, t_u8 byte, t_usize count);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_set_zero.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:58:11 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:24:51 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_SET_ZERO_H
# define MEM_SET_ZERO_H
# include "me/types.h"
void mem_set_zero(void *buf, t_usize count);
#endif