harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

memmove.ha (328B)


      1 export fn memmove(dest: *void, src: *void, n: size) void = {
      2 	let d = dest: *[*]u8, s = src: *[*]u8;
      3 	if (d: uintptr == s: uintptr) {
      4 		return;
      5 	};
      6 
      7 	if (d: uintptr < s: uintptr) {
      8 		for (let i = 0z; i < n; i += 1) {
      9 			d[i] = s[i];
     10 		};
     11 	} else {
     12 		for (let i = 0z; i < n; i += 1) {
     13 			d[n - i - 1] = s[n - i - 1];
     14 		};
     15 	};
     16 };