mirror of https://github.com/flysand7/ciabatta.git
On the second thought memmove was correct
This commit is contained in:
parent
f9fa35febe
commit
0abfd8cf3d
|
@ -12,7 +12,6 @@ void *memcpy(void *restrict s1, const void *restrict s2, size_t n) {
|
|||
void *memmove(void *s1, const void *s2, size_t n) {
|
||||
u8* c1 = s1;
|
||||
const u8* c2 = s2;
|
||||
// Note(bumbread): shouldn't this be backwards?
|
||||
if (c1 != c2) {
|
||||
if (c1 < c2) {
|
||||
// reverse copy
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
char arr[] = "Bruh\0\0\0";
|
||||
printf("Before memmove: %s\n", &arr[0]);
|
||||
memmove(arr+3, arr, 4);
|
||||
printf("After memmove: %s\n", &arr[0]);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue