Changeset 7a817d00 in mainline
- Timestamp:
- 2008-12-23T16:48:53Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 576845ec
- Parents:
- 6b080e54
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/string.c
r6b080e54 r7a817d00 190 190 } 191 191 192 /** Move memory block with possible overlapping. */ 192 193 void *memmove(void *dst, const void *src, size_t n) 193 194 { 194 int i, j; 195 196 if (src > dst) 195 uint8_t *dp, *sp; 196 197 /* Nothing to do? */ 198 if (src == dst) 199 return dst; 200 201 /* Non-overlapping? */ 202 if (dst >= src + n || src >= dst + n) { 197 203 return memcpy(dst, src, n); 198 199 for (j = (n % sizeof(unsigned long)) - 1; j >= 0; j--) 200 ((unsigned char *) ((unsigned long *) dst))[j] = 201 ((unsigned char *) ((unsigned long *) src))[j]; 202 203 for (i = n / sizeof(unsigned long) - 1; i >=0 ; i--) 204 ((unsigned long *) dst)[i] = ((unsigned long *) src)[i]; 205 206 return (char *) dst; 204 } 205 206 /* Which direction? */ 207 if (src > dst) { 208 /* Forwards. */ 209 sp = src; 210 dp = dst; 211 212 while (n-- != 0) 213 *dp++ = *sp++; 214 } else { 215 /* Backwards. */ 216 sp = src + (n - 1); 217 dp = dst + (n - 1); 218 219 while (n-- != 0) 220 *dp-- = *sp--; 221 } 222 223 return dst; 207 224 } 208 225
Note:
See TracChangeset
for help on using the changeset viewer.