fix (utils): fixed bug in memory_compare, that lead to not comparing the 64-bit stuff

This commit is contained in:
antifallobst 2023-04-19 00:29:03 +02:00
parent 45edbfb64e
commit 88c46a8f38
1 changed files with 6 additions and 6 deletions

View File

@ -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]) {