[compiler-rt] [compiler-rt][memprof] memccpy interception (PR #155101)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 25 14:35:05 PDT 2025


================
@@ -49,6 +49,16 @@ int internal_memcmp(const void* s1, const void* s2, uptr n) {
   return 0;
 }
 
+void *internal_memccpy(void *dest, const void *src, int c, uptr n) {
+  char *d = (char *)dest;
+  const char *s = (const char *)src;
+  uptr i = 0;
+  for (; i < n && s[i] != c; ++i) d[i] = s[i];
----------------
teresajohnson wrote:

My reading of the description of memccpy is that when c is found it should also be copied, before terminating the copy. It looks like this would miss the copy of c.

https://github.com/llvm/llvm-project/pull/155101


More information about the llvm-commits mailing list