diff options
| author | Pepe20129 <72659707+Pepe20129@users.noreply.github.com> | 2024-11-12 01:46:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-11 17:46:25 -0700 |
| commit | ffc132a01bc73e8e7eea826dcdfc07b742abbe12 (patch) | |
| tree | 2e2eae75d11d78ba1a33be5e0c655e0bd6adf6cd /soh/src/code/code_801068B0.c | |
| parent | f12a2bbbb7f6201a0bc8787d23cd446a1a2b4d48 (diff) | |
Clean `__osMalloc.c` (#4351)
* Remove #ifs
* Add `NODE_IS_VALID`
* Fix current macros
* `NODE_GET_NEXT` & `NODE_GET_PREV`
* Add macros
* Use macros and general cleanup
* Fix build (hopefully)
* Address review
Diffstat (limited to 'soh/src/code/code_801068B0.c')
| -rw-r--r-- | soh/src/code/code_801068B0.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/soh/src/code/code_801068B0.c b/soh/src/code/code_801068B0.c index d673cc5e0..87434a274 100644 --- a/soh/src/code/code_801068B0.c +++ b/soh/src/code/code_801068B0.c @@ -1,24 +1,33 @@ #include "global.h" -// memmove used in __osMalloc.c -void* func_801068B0(void* dst, void* src, size_t size) { - u8* spC = dst; - u8* sp8 = src; - register s32 a3; +/** + * memmove: copies `len` bytes from memory starting at `src` to memory starting at `dest`. + * + * Unlike memcpy(), the regions of memory may overlap. + * + * @param dest address of start of buffer to write to + * @param src address of start of buffer to read from + * @param len number of bytes to copy. + * + * @return dest + */ +void* oot_memmove(void* dest, const void* src, size_t len) { + char* d = dest; + const char* s = src; - if (spC == sp8) { - return dst; + if (d == s) { + return dest; } - if (spC < sp8) { - for (a3 = size--; a3 != 0; a3 = size--) { - *spC++ = *sp8++; + if (d < s) { + while (len--) { + *d++ = *s++; } } else { - spC += size - 1; - sp8 += size - 1; - for (a3 = size--; a3 != 0; a3 = size--) { - *spC-- = *sp8--; + d += len - 1; + s += len - 1; + while (len--) { + *d-- = *s--; } } - return dst; + return dest; } |
