diff --git a/kernel/src/utils/memory.c b/kernel/src/utils/memory.c index deb96cb..7883510 100644 --- a/kernel/src/utils/memory.c +++ b/kernel/src/utils/memory.c @@ -16,8 +16,8 @@ void memory_copy(void* source, void* destination, uint32_t num) { } uint32_t num_8 = num % 8; - uint8_t* src_8 = &((uint8_t*)source)[num_64 * 8]; - uint8_t* dst_8 = &((uint8_t*)destination)[num_64 * 8]; + uint8_t* src_8 = &((uint8_t*)source)[num - num_8]; + uint8_t* dst_8 = &((uint8_t*)destination)[num - num_8]; for (uint32_t i = 0; i < num_8; i++) { dst_8[i] = src_8[i]; @@ -36,7 +36,7 @@ void memory_set(void* destination, uint8_t data, uint32_t num) { } uint32_t num_8 = num % 8; - uint8_t* dst_8 = &((uint8_t*)destination)[num_64 * 8]; + uint8_t* dst_8 = &((uint8_t*)destination)[num - num_8]; for (uint32_t i = 0; i < num_8; i++) { dst_8[i] = data; @@ -48,15 +48,15 @@ bool memory_compare(void* a, void* b, uint32_t num) { uint64_t* a_64 = (uint64_t*)a; uint64_t* b_64 = (uint64_t*)b; - for (uint32_t i = num_64; i < num_64; i++) { + for (uint32_t i = 0; i < num_64; i++) { if (a_64[i] != b_64[i]) { return false; } } uint32_t num_8 = num % 8; - uint8_t* a_8 = &((uint8_t*)a)[num_64 * 8]; - uint8_t* b_8 = &((uint8_t*)b)[num_64 * 8]; + uint8_t* a_8 = &((uint8_t*)a)[num - num_8]; + uint8_t* b_8 = &((uint8_t*)b)[num - num_8]; for (uint32_t i = 0; i < num_8; i++) { if (a_8[i] != b_8[i]) {