explain_strdup_or_die(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

✨ 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 the strdup(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 ⭐


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