diff options
-rw-r--r-- | strings.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -82,13 +82,9 @@ void memcpy(void *dst, void *src, size_t nbytes) { size_t iter; - // copying by word is faster than by byte - // copy by word as much as possible - for (iter = 0; iter < nbytes / 4; iter++) - ((volatile uint32_t*) dst)[iter] = ((uint32_t*) src)[iter]; - - // copy the remaining 1, 2 or 3 bytes by byte - for (iter *= 4; iter < nbytes; iter++) + // copying by word is faster than by byte, + // but can easily cause alignment faults, so we resign from it... + for (iter = 0; iter < nbytes ; iter++) ((volatile uint8_t*) dst)[iter] = ((uint8_t*) src)[iter]; } |