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
This commit is contained in:
parent
3cadabea0a
commit
ed64bd73d6
8 changed files with 75 additions and 69 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/31 15:18:17 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 <stddef.h>
|
# include <stddef.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
void ft_bzero(void *s, size_t n);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,13 @@
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/07 16:43: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 "memory.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @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)
|
void ft_bzero(void *s, size_t n)
|
||||||
{
|
{
|
||||||
ft_memset(s, 0, n);
|
ft_memset(s, 0, n);
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,13 @@
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/07 16:47:17 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 "memory.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @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)
|
void *ft_calloc(size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
size_t total;
|
size_t total;
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,13 @@
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/07 16:48:30 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 "memory.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @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)
|
void *ft_memchr(const void *s, int c, size_t n)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
|
||||||
|
|
@ -6,24 +6,12 @@
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/07 16:49:04 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 <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @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)
|
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,12 @@
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/07 16:49:46 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 <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @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)
|
void *ft_memcpy(void *dest, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/07 16:51:35 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);
|
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)
|
void *ft_memmove(void *dest, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,12 @@
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/07 16:50:29 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 <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @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)
|
void *ft_memset(void *s, int c, size_t n)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue