shithub: orca

Download patch

ref: f93252591d7f9e80979259b24a571b72699e5d8e
parent: 2221238076d35b2e3e0d4b0db1c01938694f0cb7
author: cancel <cancel@cancel.fm>
date: Fri Nov 30 16:47:58 EST 2018

Remove use of memcpy in sim.c

--- a/sim.c
+++ b/sim.c
@@ -2,6 +2,16 @@
 #include "mark.h"
 #include "sim.h"
 
+#if 0
+ORCA_FORCE_STATIC_INLINE void stupid_memcpy(char* restrict dest,
+                                            char* restrict src, size_t sz) {
+  for (size_t i = 0; i < sz; ++i) {
+    dest[i] = src[i];
+  }
+}
+#define ORCA_MEMCPY(_dest, _src, _sz) memcpy(_dest, _src, _sz)
+#endif
+
 //////// Utilities
 
 static Glyph const indexed_glyphs[] = {
@@ -508,9 +518,15 @@
     Glyph buff[15];
     Glyph* gs = gbuffer + y * width + x + 1;
     Glyph hopped = *gs;
-    memcpy(buff, gs + 1, len - 1);
+    // ORCA_MEMCPY(buff, gs + 1, len - 1);
+    for (Usz i = 0; i < len - 1; ++i) {
+      buff[i] = gs[i + 1];
+    }
     buff[len - 1] = hopped;
-    memcpy(gs, buff, len);
+    // ORCA_MEMCPY(gs, buff, len);
+    for (Usz i = 0; i < len; ++i) {
+      gs[i] = buff[i];
+    }
     for (Usz i = 0; i < len; ++i) {
       STUN(0, (Isz)i + 1);
     }