diff options
Diffstat (limited to 'usr/klibc/memswap.c')
-rw-r--r-- | usr/klibc/memswap.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/usr/klibc/memswap.c b/usr/klibc/memswap.c new file mode 100644 index 0000000..b32315c --- /dev/null +++ b/usr/klibc/memswap.c @@ -0,0 +1,24 @@ +/* + * memswap() + * + * Swaps the contents of two nonoverlapping memory areas. + * This really could be done faster... + */ + +#include <string.h> + +void memswap(void *m1, void *m2, size_t n) +{ + char *p = m1; + char *q = m2; + char tmp; + + while (n--) { + tmp = *p; + *p = *q; + *q = tmp; + + p++; + q++; + } +} |