[PATCH] Improve strncpy performance further

Wilco Dijkstra wdijkstr@arm.com
Fri Jan 9 13:08:00 GMT 2015


> Roland McGrath:
> Has to be __strnlen.

Good point, so it becomes:

-  return s;
+  size_t size = __strnlen (s2, n);
+  if (size != n)
+    memset (s1 + size, '\0', n - size);
+  return memcpy (s1, s2, size);

Btw while on the subject on namespaces, is bcopy correctly defined?
After a lot of complex inclusion and defines, it ultimately does:

void
bcopy ()
{
...
}

Wilco





More information about the Libc-alpha mailing list