From ed64bd73d6a414d57f487ea0219329fab2917594 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 5 Sep 2025 16:29:40 +0200 Subject: [PATCH] docs(memory): moving the actual documentation on the header - The documentation on the header allow u to see on the files where the header is inclued --- includes/memory.h | 69 ++++++++++++++++++++++++++++++++++++++++++++- memory/ft_bzero.c | 8 +----- memory/ft_calloc.c | 8 +----- memory/ft_memchr.c | 12 +------- memory/ft_memcmp.c | 14 +-------- memory/ft_memcpy.c | 11 +------- memory/ft_memmove.c | 11 +------- memory/ft_memset.c | 11 +------- 8 files changed, 75 insertions(+), 69 deletions(-) diff --git a/includes/memory.h b/includes/memory.h index 8ed4031..a410e96 100644 --- a/includes/memory.h +++ b/includes/memory.h @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 15:18:17 by rparodi #+# #+# */ -/* Updated: 2025/09/04 11:51:05 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:36 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,12 +15,79 @@ # include +/** + * @brief Compares two memory blocks + * + * @param s1 Pointer to the first memory area + * @param s2 Pointer to the second memory area + * @param n Number of bytes to compare + * + * @return An integer indicating the relationship between the two memory areas: + * - `< 0` if `s1` is less than `s2` + * - `0` if `s1` equals `s2` + * - `> 0` if `s1` is greater than `s2` + */ int ft_memcmp(const void *s1, const void *s2, size_t n); + +/** + * @brief Allocates and zeroes memory for an array + * + * @param nmemb Number of elements to allocate + * @param size Size of each element in bytes + */ void *ft_calloc(size_t nmemb, size_t size); + +/** + * @brief Scans memory for a byte + * + * @param s Pointer to the memory area to scan + * @param c Byte value to search for + * @param n Number of bytes to scan in s + * + * @return A pointer to the matching byte in memory, or NULL if the byte +is not found within the first n bytes + */ void *ft_memchr(const void *s, int c, size_t n); + +/** + * @brief Copies memory from source to destination + * + * @param dest Pointer to the destination memory area + * @param src Pointer to the source memory area + * @param n Number of bytes to copy from src to dest + * + * @return A pointer to the destination memory area dest + */ void *ft_memcpy(void *dest, const void *src, size_t n); + +/** + * @brief Copies memory with overlap handling + * + * @param dest Pointer to the destination memory area + * @param src Pointer to the source memory area + * @param n Number of bytes to copy from src to dest + * + * @return A pointer to the destination memory area dest + */ void *ft_memmove(void *dest, const void *src, size_t n); + +/** + * @brief Fills a block of memory with a specified byte + * + * @param s Pointer to the memory area to fill + * @param c Byte value to be set in the memory + * @param n Number of bytes to be set to the value c + * + * @return A pointer to the memory area s + */ void *ft_memset(void *s, int c, size_t n); + +/** + * @brief Sets a block of memory to zero + * + * @param s Pointer to the memory area to be set at zero + * @param n Number of bytes to set to zero + */ void ft_bzero(void *s, size_t n); #endif diff --git a/memory/ft_bzero.c b/memory/ft_bzero.c index 732ea50..2316d16 100644 --- a/memory/ft_bzero.c +++ b/memory/ft_bzero.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:43:13 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:39:50 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:53 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "memory.h" #include -/** - * @brief Sets a block of memory to zero - * - * @param s Pointer to the memory area to be set at zero - * @param n Number of bytes to set to zero - */ void ft_bzero(void *s, size_t n) { ft_memset(s, 0, n); diff --git a/memory/ft_calloc.c b/memory/ft_calloc.c index 3f7583f..decbc8f 100644 --- a/memory/ft_calloc.c +++ b/memory/ft_calloc.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:47:17 by rparodi #+# #+# */ -/* Updated: 2025/09/01 18:28:34 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:25:35 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "memory.h" #include -/** - * @brief Allocates and zeroes memory for an array - * - * @param nmemb Number of elements to allocate - * @param size Size of each element in bytes - */ void *ft_calloc(size_t nmemb, size_t size) { size_t total; diff --git a/memory/ft_memchr.c b/memory/ft_memchr.c index 1d8bb75..e1457ff 100644 --- a/memory/ft_memchr.c +++ b/memory/ft_memchr.c @@ -6,23 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:48:30 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:40:36 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:04 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "memory.h" #include -/** - * @brief Scans memory for a byte - * - * @param s Pointer to the memory area to scan - * @param c Byte value to search for - * @param n Number of bytes to scan in s - * - * @return A pointer to the matching byte in memory, or NULL if the byte -is not found within the first n bytes - */ void *ft_memchr(const void *s, int c, size_t n) { size_t i; diff --git a/memory/ft_memcmp.c b/memory/ft_memcmp.c index 7c3d955..be12fcb 100644 --- a/memory/ft_memcmp.c +++ b/memory/ft_memcmp.c @@ -6,24 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:49:04 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:40:58 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:04 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @brief Compares two memory blocks - * - * @param s1 Pointer to the first memory area - * @param s2 Pointer to the second memory area - * @param n Number of bytes to compare - * - * @return An integer indicating the relationship between the two memory areas: - * - `< 0` if `s1` is less than `s2` - * - `0` if `s1` equals `s2` - * - `> 0` if `s1` is greater than `s2` - */ int ft_memcmp(const void *s1, const void *s2, size_t n) { size_t i; diff --git a/memory/ft_memcpy.c b/memory/ft_memcpy.c index 4c35af1..442c6b9 100644 --- a/memory/ft_memcpy.c +++ b/memory/ft_memcpy.c @@ -6,21 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:49:46 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:41:32 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:04 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @brief Copies memory from source to destination - * - * @param dest Pointer to the destination memory area - * @param src Pointer to the source memory area - * @param n Number of bytes to copy from src to dest - * - * @return A pointer to the destination memory area dest - */ void *ft_memcpy(void *dest, const void *src, size_t n) { char *d; diff --git a/memory/ft_memmove.c b/memory/ft_memmove.c index 6d63e80..010d283 100644 --- a/memory/ft_memmove.c +++ b/memory/ft_memmove.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:51:35 by rparodi #+# #+# */ -/* Updated: 2025/09/04 11:56:02 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:53 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,15 +37,6 @@ static char *ft_checks(char *s, char *d, size_t n) return (d); } -/** - * @brief Copies memory with overlap handling - * - * @param dest Pointer to the destination memory area - * @param src Pointer to the source memory area - * @param n Number of bytes to copy from src to dest - * - * @return A pointer to the destination memory area dest - */ void *ft_memmove(void *dest, const void *src, size_t n) { char *d; diff --git a/memory/ft_memset.c b/memory/ft_memset.c index e4825d6..dd0cde5 100644 --- a/memory/ft_memset.c +++ b/memory/ft_memset.c @@ -6,21 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:50:29 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:42:01 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:53 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @brief Fills a block of memory with a specified byte - * - * @param s Pointer to the memory area to fill - * @param c Byte value to be set in the memory - * @param n Number of bytes to be set to the value c - * - * @return A pointer to the memory area s - */ void *ft_memset(void *s, int c, size_t n) { char *str;