[PATCH 5/8] lib/string.c: implement strdup() and strndup() in terms of memdup_nul()

Simon Glass sjg at chromium.org
Mon Apr 13 16:57:22 CEST 2026


On 2026-04-12T19:59:41, Rasmus Villemoes <ravi at prevas.dk> wrote:
> 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.
>
> Signed-off-by: Rasmus Villemoes <ravi at prevas.dk>
>
> lib/string.c | 30 ++----------------------------
>  1 file changed, 2 insertions(+), 28 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list