minishell
ft_memmove.c File Reference
#include <string.h>
#include "ft_mem.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 n)
 

Function Documentation

◆ ft_memmove()

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

Definition at line 16 of file ft_memmove.c.

17 {
18  unsigned char *p_c_dst;
19  unsigned char *p_c_src;
20  signed char direction;
21 
22  if (src == dst || n == 0)
23  return (dst);
24  p_c_dst = (unsigned char *)dst;
25  p_c_src = (unsigned char *)src;
26  if (dst > src)
27  {
28  p_c_dst += n - 1;
29  p_c_src += n - 1;
30  direction = -1;
31  }
32  else
33  direction = 1;
34  while (n-- > 0)
35  {
36  *p_c_dst = *p_c_src;
37  p_c_dst += direction;
38  p_c_src += direction;
39  }
40  return (dst);
41 }
Here is the caller graph for this function: