diff --git a/kernel/src/utils/memory.c b/kernel/src/utils/memory.c index 72908ff..9a46a21 100644 --- a/kernel/src/utils/memory.c +++ b/kernel/src/utils/memory.c @@ -28,10 +28,10 @@ void memory_copy(void* source, void* destination, uint32_t num) { } uint32_t num_8 = num % 8; - uint8_t* src_8 = (uint8_t*)source; - uint8_t* dst_8 = (uint8_t*)destination; + uint8_t* src_8 = &((uint8_t*)source)[num_64 * 8]; + uint8_t* dst_8 = &((uint8_t*)destination)[num_64 * 8]; - for (uint32_t i = num_64 * 8; i < num_8; i++) { + for (uint32_t i = 0; i < num_8; i++) { dst_8[i] = src_8[i]; } } @@ -48,9 +48,9 @@ void memory_set(void* destination, uint8_t data, uint32_t num) { } uint32_t num_8 = num % 8; - uint8_t* dst_8 = (uint8_t*)destination; + uint8_t* dst_8 = &((uint8_t*)destination)[num_64 * 8]; - for (uint32_t i = num_64 * 8; i < num_8; i++) { + for (uint32_t i = 0; i < num_8; i++) { dst_8[i] = data; } } @@ -67,10 +67,10 @@ bool memory_compare(void* a, void* b, uint32_t num) { } uint32_t num_8 = num % 8; - uint8_t* a_8 = (uint8_t*)a; - uint8_t* b_8 = (uint8_t*)b; + uint8_t* a_8 = &((uint8_t*)a)[num_64 * 8]; + uint8_t* b_8 = &((uint8_t*)b)[num_64 * 8]; - for (uint32_t i = num_64 * 8; i < num_8; i++) { + for (uint32_t i = 0; i < num_8; i++) { if (a_8[i] != b_8[i]) { return false; }