Changeset ac48fef in mainline
- Timestamp:
- 2008-12-27T11:28:06Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9a63657
- Parents:
- b755225
- Location:
- kernel/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/memstr.h
rb755225 rac48fef 45 45 extern void _memsetb(void *dst, size_t cnt, uint8_t x); 46 46 extern void _memsetw(void *dst, size_t cnt, uint16_t x); 47 extern void *memmove(void *dst, const void *src, size_t cnt); 48 47 49 extern char *strcpy(char *dest, const char *src); 48 50 -
kernel/generic/src/lib/memstr.c
rb755225 rac48fef 1 1 /* 2 2 * Copyright (c) 2001-2004 Jakub Jermar 3 * Copyright (c) 2008 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 77 78 } 78 79 80 /** Move memory block with possible overlapping. 81 * 82 * Copy cnt bytes from src address to dst address. The source and destination 83 * memory areas may overlap. 84 * 85 * @param src Source address to copy from. 86 * @param dst Destination address to copy to. 87 * @param cnt Number of bytes to copy. 88 * 89 * @return Destination address. 90 */ 91 void *memmove(void *dst, const void *src, size_t n) 92 { 93 const uint8_t *sp; 94 uint8_t *dp; 95 96 /* Nothing to do? */ 97 if (src == dst) 98 return dst; 99 100 /* Non-overlapping? */ 101 if (dst >= src + n || src >= dst + n) { 102 return memcpy(dst, src, n); 103 } 104 105 /* Which direction? */ 106 if (src > dst) { 107 /* Forwards. */ 108 sp = src; 109 dp = dst; 110 111 while (n-- != 0) 112 *dp++ = *sp++; 113 } else { 114 /* Backwards. */ 115 sp = src + (n - 1); 116 dp = dst + (n - 1); 117 118 while (n-- != 0) 119 *dp-- = *sp--; 120 } 121 122 return dst; 123 } 124 79 125 /** Fill block of memory 80 126 *
Note:
See TracChangeset
for help on using the changeset viewer.