software/libbase: fix memcpy handling of buffers with differing alignments
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Sun, 27 May 2012 13:45:45 +0000 (15:45 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Sun, 27 May 2012 13:45:45 +0000 (15:45 +0200)
software/libbase/libc.c

index 78e3823feeee1f8d6c0a1258af9b4c123c027916..d0667f1cdfdcc2a345e6a2f8172c355d3a31e380 100644 (file)
@@ -265,6 +265,13 @@ void *memcpy(void *to, const void *from, size_t n)
                from = cfrom;
                n--;
        }
+       if((long)from & 1) {
+               char *cto = to;
+               const char *cfrom = from;
+               for (; n; n--)
+                       *cto++ = *cfrom++;
+               return xto;
+       }
        if(n > 2 && (long)to & 2) {
                short *sto = to;
                const short *sfrom = from;
@@ -278,7 +285,7 @@ void *memcpy(void *to, const void *from, size_t n)
                long *lto = to;
                const long *lfrom = from;
                for(; temp; temp--)
-               *lto++ = *lfrom++;
+                       *lto++ = *lfrom++;
                to = lto;
                from = lfrom;
        }