maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_memmove.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_memmove.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: rmikhayl <rmikhayl@student.42london.c +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2023/12/17 17:25:27 by rmikhayl #+# #+# */
9
/* Updated: 2023/12/17 17:25:27 by rmikhayl ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
libft.h
"
14
15
/* *************************** ft_memmove *********************************** */
16
/* Moves 'n' bytes from 'src' to 'dest' without overlap and returns 'dest'. */
17
/* The original 'src' memory remains unchanged. */
18
/* */
19
/* In layman's terms: It safely shifts a block of data from one place to */
20
/* another without causing any issues or conflicts and gives you the */
21
/* destination. */
22
/* ************************************************************************** */
23
24
void
*
ft_memmove
(
void
*dest,
const
void
*src,
size_t
n)
25
{
26
char
*d;
27
const
char
*s;
28
29
d = dest;
30
s = src;
31
if
(d == s)
32
return
(dest);
33
if
(d < s || d >= s + n)
34
ft_memcpy
(d, s, n);
35
else
36
{
37
d += n;
38
s += n;
39
while
(n--)
40
*(--d) = *(--s);
41
}
42
return
(dest);
43
}
ft_memmove
void * ft_memmove(void *dest, const void *src, size_t n)
Definition
ft_memmove.c:24
libft.h
ft_memcpy
void * ft_memcpy(void *dest, const void *src, size_t n)
Definition
ft_memcpy.c:22
lib
libft
src
ft_memmove.c
Generated by
1.9.8