explain_strndup_or_die(3)                            explain_strndup_or_die(3)



NNAAMMEE
       explain_strndup_or_die - duplicate a string and report errors

SSYYNNOOPPSSIISS
       #include <libexplain/strndup.h>
       char *explain_strndup_or_die(const char *data, size_t data_size);
       char *explain_strndup_on_error(const char *data, size_t data_size);

DDEESSCCRRIIPPTTIIOONN
       The eexxppllaaiinn__ssttrrnndduupp__oorr__ddiiee function is used to call the _s_t_r_n_d_u_p(3) sys-
       tem call. On failure an explanation will be printed to _s_t_d_e_r_r, obtained
       from  the  _e_x_p_l_a_i_n___s_t_r_n_d_u_p(3) function, and then the process terminates
       by calling exit(EXIT_FAILURE).

       The eexxppllaaiinn__ssttrrnndduupp__oonn__eerrrroorr function is used to  call  the  _s_t_r_n_d_u_p(3)
       system  call.  On  failure  an  explanation  will be printed to _s_t_d_e_r_r,
       obtained from the _e_x_p_l_a_i_n___s_t_r_n_d_u_p(3) function, but still returns to the
       caller.

       _d_a_t_a    The  data,  exactly  as  to  be passed to the _s_t_r_n_d_u_p(3) system
               call.

       _d_a_t_a___s_i_z_e
               The data_size, exactly as to be passed to the _s_t_r_n_d_u_p(3) system
               call.

RREETTUURRNN VVAALLUUEE
       The  eexxppllaaiinn__ssttrrnndduupp__oorr__ddiiee  function  only  returns  on  success,  see
       _s_t_r_n_d_u_p(3) for more information. On failure, prints an explanation  and
       exits, it does not return.

       The  eexxppllaaiinn__ssttrrnndduupp__oonn__eerrrroorr  function always returns the value return
       by the wrapped _s_t_r_n_d_u_p(3) system call.

EEXXAAMMPPLLEE
       The eexxppllaaiinn__ssttrrnndduupp__oorr__ddiiee function is intended to be used in a fashion
       similar to the following example:
              char *result = explain_strndup_or_die(data, data_size);

SSEEEE AALLSSOO
       _s_t_r_n_d_u_p(3)
               duplicate a string

       _e_x_p_l_a_i_n___s_t_r_n_d_u_p(3)
               explain _s_t_r_n_d_u_p(3) errors

       _e_x_i_t(2) terminate the calling process

CCOOPPYYRRIIGGHHTT
       libexplain version 1.4
       Copyright (C) 2009 Peter Miller



                                                     explain_strndup_or_die(3)
