explain_strdup_or_die(3)
β¨ explain_strdup_or_die(3) β¨
okay bestie, welcome to the Library Functions Manual π this is the page for explain_strdup_or_die, and yes the name is a whole mouthful but we're gonna get through it together, fr fr π«Ά
πΈ NAME πΈ
explain_strdup_or_die β duplicate a string and report errors π
π SYNOPSIS π
#include <libexplain/strdup.h>
char *explain_strdup_or_die(const char *data);
char *explain_strdup_on_error(const char *data);
π¦ DESCRIPTION π¦
So here's the tea β β there are two little functions on this page and they're like sisters, same energy, different endings.
The explain_strdup_or_die function is used to call the strdup(3) system call. When it goes wrong? An explanation gets printed to stderr, and that explanation is obtained from the explain_strdup(3) function. Then β and this is the dramatic part π β the process terminates by calling exit(EXIT_FAILURE). Like, it does not come back. It's giving final boss energy. π
The explain_strdup_on_error function is also used to call the strdup(3) system call, and on failure it also prints an explanation to stderr obtained from the explain_strdup(3) function β but this one is chill π§ it still returns to the caller. No dying today bestie β¨
the parameter π
dataβ the data, exactly as to be passed to thestrdup(3)system call. literally exactly, don't get cute with it π
π RETURN VALUE π
The explain_strdup_or_die function only returns on success β see strdup(3) for more information. On failure it prints an explanation and exits, so likeβ¦ it does not return. it's gone. bye π
The explain_strdup_on_error function always returns the value returned by the wrapped strdup(3) system call. every single time, no cap π«Ά
π EXAMPLE π
The explain_strdup_or_die function is intended to be used in a fashion similar to the following example:
char *result = explain_strdup_or_die(data);
look at her go π iconic honestly
β SEE ALSO β
strdup(3)β duplicate a stringexplain_strdup(3)β explainstrdup(3)errorsexit(2)β terminate the calling process
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2009 Peter Miller
and that's the whole page bestie, we ate and left no crumbs π
πΈ this was explain_strdup_or_die(3) from the Library Functions Manual β libexplain version 1.4, copyright (C) 2009 Peter Miller. mwah, go forth and duplicate those strings responsibly πβ¨π¦
π¦ where this page comes from
- debian bookworm: libexplain-dev 1.4.D001-12+b1 Β· LGPL-3.0-or-later
- debian trixie: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- ubuntu jammy: libexplain-dev 1.4.D001-12 Β· LGPL-3.0-or-later
- ubuntu noble: libexplain-dev 1.4.D001-13 Β· LGPL-3.0-or-later
- ubuntu resolute: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- Copyright (C) 2009, 2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms