diff options
| author | cadmic <cadmic24@gmail.com> | 2024-12-08 15:55:14 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-08 18:55:14 -0500 |
| commit | 40930acf113f687d7fd4de3d832f593a6390ac4b (patch) | |
| tree | 507851623d97783ec91bd69e3ae84100515e6a50 /src/code/z_memory_utils.c | |
| parent | 64de4a0f5d6de17cf647a0ac532821cd474e9b88 (diff) | |
Rename code_80069420.c -> z_memory_utils.c (#2314)
* Rename code_80069420.c -> z_memory.c
* z_memory -> z_memory_utils
Diffstat (limited to 'src/code/z_memory_utils.c')
| -rw-r--r-- | src/code/z_memory_utils.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/code/z_memory_utils.c b/src/code/z_memory_utils.c new file mode 100644 index 000000000..a08567dd6 --- /dev/null +++ b/src/code/z_memory_utils.c @@ -0,0 +1,49 @@ +#include "ultra64.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 + */ +void* MemCpy(void* dest, const void* src, s32 len) { + u8* d = dest; + const u8* s = src; + + while (len > 0) { + *d++ = *s++; + len--; + } + + 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 + */ +void* MemSet(void* dest, s32 val, s32 len) { + u8* d = dest; + s32 s = len; + + while (s > 0) { + *d++ = val; + s--; + } + + return dest; +} |
