PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
memmove.c
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#define SYSCLIB_DISABLE_BUILTINS
12#include <sysclib.h>
13
14void *memmove(void *dest, const void *src, size_t size)
15{
16 u8 *v3;
17 void *result;
18 s32 v5;
19
20 v3 = dest;
21 if (!dest)
22 {
23 return 0;
24 }
25 if (dest < src)
26 {
27 result = dest;
28 if (size > 0)
29 {
30 do
31 {
32 char v8;
33
34 v8 = *(u8 *)src;
35 src = (u8 *)src + 1;
36 size -= 1;
37 *v3++ = v8;
38 }
39 while (size > 0);
40 return dest;
41 }
42 }
43 else
44 {
45 v5 = (s32)size - 1;
46 result = dest;
47 if (v5 >= 0)
48 {
49 do
50 {
51 u8 *v6;
52 char v7;
53
54 v6 = (u8 *)dest + v5;
55 v7 = *((u8 *)src + v5--);
56 *v6 = v7;
57 }
58 while (v5 >= 0);
59 return dest;
60 }
61 }
62 return result;
63}