Created
March 27, 2012 00:51
-
-
Save objectx/2211201 to your computer and use it in GitHub Desktop.
An annoying way to copy a region. Don't try this anymore.
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
#include <sys/types.h> | |
void copy (char *dst, char *src, size_t size) { | |
if (size == 0) { | |
return ; | |
} | |
size_t sz = size / 4 ; | |
switch (size % 4) { | |
while (sz-- != 0) { | |
default: | |
*dst++ = *src++ ; | |
case 3: | |
*dst++ = *src++ ; | |
case 2: | |
*dst++ = *src++ ; | |
case 1: | |
*dst++ = *src++ ; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment