]> git.ipfire.org Git - thirdparty/u-boot.git/commit
lib/string.c: implement strdup() and strndup() in terms of memdup_nul()
authorRasmus Villemoes <ravi@prevas.dk>
Tue, 21 Apr 2026 07:54:35 +0000 (09:54 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 12 May 2026 21:38:00 +0000 (15:38 -0600)
commitee8be5d4a1035de232b3497563fe9f6773775f96
treec56925568ea459e1b7d151e0ad068f8b87e8573f
parent8c664d2135723a110a60b792a8614c4864ad82a3
lib/string.c: implement strdup() and strndup() in terms of memdup_nul()

With the addition of memdup_nul(), strdup() and strndup() can be
implemented as one-liners.

While not required by POSIX or C, do keep the behaviour of gracefully
accepting a NULL source and simply return NULL.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
lib/string.c