diff options
| author | Dragorn421 <Dragorn421@users.noreply.github.com> | 2026-08-05 18:32:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-05 18:32:30 +0200 |
| commit | 05e9046417d11d8a9660074b1c014023b337eb27 (patch) | |
| tree | 4dd9f4d093340022dc51d6977763fe017348711b /src/code/z_memory_utils.c | |
| parent | a883cd019a6952d53e6f76c2882c79c4e6cb2c31 (diff) | |
[cc0 oot] z_memory_utils (#2783)
* [cc0 oot] z_memory_utils
* format
* doc
* MemCopy: The memory regions must not overlap.
Diffstat (limited to 'src/code/z_memory_utils.c')
| -rw-r--r-- | src/code/z_memory_utils.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/src/code/z_memory_utils.c b/src/code/z_memory_utils.c index a08567dd6..dd184d94a 100644 --- a/src/code/z_memory_utils.c +++ b/src/code/z_memory_utils.c @@ -1,47 +1,31 @@ #include "ultra64.h" +#include "memory_utils.h" /** - * memcpy: copies `len` bytes from memory starting at `src` to memory starting at `dest`. Expects the memory - * specified by `src` and `dest` to not overlap. - * - * @see libultra also has a memcpy(). - * - * @param dest address of start of buffer writing to - * @param src address of start of buffer to read from - * @param len number of bytes to copy. (`s32` rather than the standard `size_t`) - * - * @return dest + * Copy `size` bytes from `src` to `dest`. + * The memory regions must not overlap. */ -void* MemCpy(void* dest, const void* src, s32 len) { - u8* d = dest; - const u8* s = src; +void* MemCopy(void* dest, void* src, s32 size) { + u8* destu = (u8*)dest; + u8* srcu = (u8*)src; - while (len > 0) { - *d++ = *s++; - len--; + while (size > 0) { + *destu++ = *srcu++; + size--; } return dest; } /** - * memset: sets `len` bytes to `val` starting at address `dest`. - * - * @see There are two other memsets in this codebase, Lib_MemSet(), memset(). - * This one is unused. - * - * @param dest address to start at - * @param val value to write (`s32`, but interpreted as `u8`) - * @param len number of bytes to write. (`s32` rather than the standard `size_t`) - * - * @return dest + * Set `size` bytes starting at `dest` to value `val`. */ -void* MemSet(void* dest, s32 val, s32 len) { - u8* d = dest; - s32 s = len; +void* MemSet(void* dest, s32 val, s32 size) { + u8* destu = (u8*)dest; + s32 s = size; while (s > 0) { - *d++ = val; + *destu++ = val; s--; } |
