eread(3) exit-on-failure wrapper functions

Other Alias

ecalloc, emalloc, erealloc, esetenv, estrdup, ewrite


The roken library (libroken, -lroken)


Fd #include <roken.h> Ft void * Fn ecalloc size_t number size_t size Ft void * Fn emalloc size_t sz Ft ssize_t Fn eread int fd void *buf size_t nbytes Ft void * Fn erealloc void *ptr size_t sz Ft void Fn esetenv const char *var const char *val int rewrite Ft char * Fn estrdup const char *str Ft ssize_t Fn ewrite int fd const void *buf size_t nbytes


These functions do the same as the ones without the ``e'' prefix, but if there is an error they will print a message with errx(3), and exit. For eread and ewrite this is also true for partial data.

This is useful in applications when there is no need for a more advanced failure mode.