---
name: "erealloc"
section: "3"
platform: "linux"
package: "heimdal-dev"
version: "7.8.git20221117.28daf24+dfsg-9+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://carta.tech/man/ecalloc"
---

# erealloc(3)

exit-on-failure wrapper functions

Part of [ecalloc(3)](/man/ecalloc/3.md).

## NAME

**ecalloc**, **emalloc**, **eread**, **erealloc**, **esetenv**, **estrdup**, **ewrite** – exit-on-failure wrapper functions

## LIBRARY

The roken library (libroken, -lroken)

## 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

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/errx/3.md), 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

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