ECALLOC(3) Library Functions Manual ECALLOC(3)

# [NAME](#NAME)

`ecalloc`, `emalloc`, `eread`, `erealloc`, `esetenv`, `estrdup`, `ewrite` — exit-on-failure wrapper functions

# [LIBRARY](#LIBRARY)

The roken library (libroken, -lroken)

# [SYNOPSIS](#SYNOPSIS)

`#include <roken.h>`

`void *`  
`ecalloc`(`size_t number`, `size_t size`);

`void *`  
`emalloc`(`size_t sz`);

`ssize_t`  
`eread`(`int fd`, `void *buf`, `size_t nbytes`);

`void *`  
`erealloc`(`void *ptr`, `size_t sz`);

`void`  
`esetenv`(`const char *var`, `const char *val`, `int rewrite`);

`char *`  
`estrdup`(`const char *str`);

`ssize_t`  
`ewrite`(`int fd`, `const void *buf`, `size_t nbytes`);

# [DESCRIPTION](#DESCRIPTION)

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)](/man/os/heimdal/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.

# [SEE ALSO](#SEE_ALSO)

[read(2)](/man/os/heimdal/read.2), [write(2)](/man/os/heimdal/write.2), [calloc(3)](/man/os/heimdal/calloc.3), [errx(3)](/man/os/heimdal/errx.3), [malloc(3)](/man/os/heimdal/malloc.3), [realloc(3)](/man/os/heimdal/realloc.3), [setenv(3)](/man/os/heimdal/setenv.3), [strdup(3)](/man/os/heimdal/strdup.3)

August 14, 2003 HEIMDAL

---

Document: ecalloc(3) from heimdal 7.8.0-r52 (Chainguard OS)
Source: https://github.com/heimdal/heimdal
