Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…ments
  • Loading branch information...
commit 48b70f09a87ae5c06e62fc29ecd2d480e8b4198d 1 parent 4dbc938
Sébastien Bourdeauducq authored May 27, 2012

Showing 1 changed file with 8 additions and 1 deletion. Show diff stats Hide diff stats

  1. 9  software/libbase/libc.c
9  software/libbase/libc.c
@@ -265,6 +265,13 @@ void *memcpy(void *to, const void *from, size_t n)
265 265
 		from = cfrom;
266 266
 		n--;
267 267
 	}
  268
+	if((long)from & 1) {
  269
+		char *cto = to;
  270
+		const char *cfrom = from;
  271
+		for (; n; n--)
  272
+			*cto++ = *cfrom++;
  273
+		return xto;
  274
+	}
268 275
 	if(n > 2 && (long)to & 2) {
269 276
 		short *sto = to;
270 277
 		const short *sfrom = from;
@@ -278,7 +285,7 @@ void *memcpy(void *to, const void *from, size_t n)
278 285
 		long *lto = to;
279 286
 		const long *lfrom = from;
280 287
 		for(; temp; temp--)
281  
-		*lto++ = *lfrom++;
  288
+			*lto++ = *lfrom++;
282 289
 		to = lto;
283 290
 		from = lfrom;
284 291
 	}

0 notes on commit 48b70f0

Please sign in to comment.
Something went wrong with that request. Please try again.