Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_memmove.c File Reference
#include <stdlib.h>
+ Include dependency graph for ft_memmove.c:

Go to the source code of this file.

Functions

void * ft_memmove (void *dst, const void *src, size_t len)
 Copies bytes between potentially overlapping memory areas.
 

Function Documentation

◆ ft_memmove()

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

Copies bytes between potentially overlapping memory areas.

Parameters
dstDestination memory area.
srcSource memory area.
lenNumber of bytes to copy.
Returns
Original dst pointer, or NULL when both pointers are NULL.

Definition at line 23 of file ft_memmove.c.

24{
25 unsigned char *d;
26 const unsigned char *s;
27
28 if (!dst && !src)
29 return (NULL);
30 d = (unsigned char *)dst;
31 s = (const unsigned char *)src;
32 if (d > s)
33 {
34 while (len--)
35 d[len] = s[len];
36 }
37 else
38 {
39 while (len--)
40 *d++ = *s++;
41 }
42 return (dst);
43}