HomeFreeBSD

libkern: strdup.c, strndup.c: Prefer memcpy() over bcopy()

Description

libkern: strdup.c, strndup.c: Prefer memcpy() over bcopy()

The newly allocated memory can not overlap with the string if the string
is properly null-terminated or the maxlen is a valid lengh, i.e no out
of bounds reads. Prefer memcpy() over memmove(), aka bcopy(), for slight
performance gain.

No functional change intended.

Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D49026

(cherry picked from commit 90a3b6a7a4e4c8201ba1bb90fb8e2b088f3a5788)

Details

Provenance
zleiAuthored on Feb 17 2025, 3:37 PM
Reviewer
kib
Differential Revision
D49026: strdup.c, strndup.c: Prefer memcpy() over bcopy()
Parents
rG8f652eb792ba: stand: Fix brand positioning on framebuffer console
Branches
Unknown
Tags
Unknown