Libft
Custom implementation of core libc functions with additional utility helpers.
Loading...
Searching...
No Matches
Memory Functions

Low-level memory operations. More...

Functions

void ft_bzero (void *s, size_t n)
 Sets n bytes of memory to zero.
void * ft_memchr (const void *s, int c, size_t n)
 Locates the first occurrence of a byte in memory.
int ft_memcmp (const void *s1, const void *s2, size_t n)
 Compares two memory areas byte by byte.
void * ft_memcpy (void *dst, const void *src, size_t n)
 Copies n bytes from src to dst.
void * ft_memmove (void *dst, const void *src, size_t len)
 Copies n bytes from src to dst, handling overlapping memory.
void * ft_memset (void *b, int c, size_t len)
 Fills memory with a constant byte.

Detailed Description

Low-level memory operations.

Functions to manipulate raw memory blocks.

Function Documentation

◆ ft_bzero()

void ft_bzero ( void * s,
size_t n )

Sets n bytes of memory to zero.

Parameters
sPointer to memory area.
nNumber of bytes to set.
Here is the caller graph for this function:

◆ ft_memchr()

void * ft_memchr ( const void * s,
int c,
size_t n )

Locates the first occurrence of a byte in memory.

Note
Returned pointer is borrowed from s. Do not free it directly.
Parameters
sMemory area to search (borrowed).
cByte to search for (converted to unsigned char).
nNumber of bytes to search.
Returns
Pointer to the byte (borrowed), or NULL if not found.

◆ ft_memcmp()

int ft_memcmp ( const void * s1,
const void * s2,
size_t n )

Compares two memory areas byte by byte.

Parameters
s1First memory area.
s2Second memory area.
nNumber of bytes to compare.
Returns
Difference of first differing bytes, or 0 if equal.

◆ ft_memcpy()

void * ft_memcpy ( void * dst,
const void * src,
size_t n )

Copies n bytes from src to dst.

Warning
Memory areas must not overlap. Use ft_memmove for overlapping.
Parameters
dstDestination memory area (borrowed).
srcSource memory area (borrowed).
nNumber of bytes to copy.
Returns
Pointer to dst.
Here is the caller graph for this function:

◆ ft_memmove()

void * ft_memmove ( void * dst,
const void * src,
size_t len )

Copies n bytes from src to dst, handling overlapping memory.

Parameters
dstDestination memory area.
srcSource memory area.
lenNumber of bytes to copy.
Returns
Pointer to dst.
Here is the caller graph for this function:

◆ ft_memset()

void * ft_memset ( void * b,
int c,
size_t len )

Fills memory with a constant byte.

Parameters
bMemory area to fill.
cByte value to set (converted to unsigned char).
lenNumber of bytes to set.
Returns
Pointer to b.
Here is the caller graph for this function: