Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

software/libbase: fix memcpy handling of buffers with differing align…

…ments
  • Loading branch information...
commit 48b70f09a87ae5c06e62fc29ecd2d480e8b4198d 1 parent 4dbc938
Sébastien Bourdeauducq sbourdeauducq authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 software/libbase/libc.c
9 software/libbase/libc.c
View
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.