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

# ewrite(3)

exit-on-failure wrapper functions

## 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)](/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)](/read/2.md), [write(2)](/write/2.md), [calloc(3)](/calloc/3.md), [errx(3)](/errx/3.md), [malloc(3)](/malloc/3.md), [realloc(3)](/realloc/3.md), [setenv(3)](/setenv/3.md), [strdup(3)](/strdup/3.md)
