Last active
August 23, 2021 00:57
-
-
Save bynect/7032ba8de7cf5e5125fc15ad840a28a7 to your computer and use it in GitHub Desktop.
Memswap implementation in ISO C.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MEMSWAP_H | |
#define MEMSWAP_H | |
static inline void | |
memswap(void *restrict aptr, void *restrict bptr, size_t len) | |
{ | |
register unsigned char *a = aptr; | |
register unsigned char *b = bptr; | |
register unsigned char t; | |
while (len--) | |
{ | |
t = *a; | |
*a++ = *b; | |
*b++ = t; | |
} | |
} | |
#endif /* MEMSWAP_H */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment