xref: /minix3/crypto/external/bsd/heimdal/dist/lib/roken/ecalloc.3 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: ecalloc.3,v 1.1.1.3 2014/04/24 12:45:52 pettai Exp $
2ebfedea0SLionel Sambuc.\"
3ebfedea0SLionel Sambuc.\" Copyright (c) 2001, 2003 Kungliga Tekniska Högskolan
4ebfedea0SLionel Sambuc.\" (Royal Institute of Technology, Stockholm, Sweden).
5ebfedea0SLionel Sambuc.\" All rights reserved.
6ebfedea0SLionel Sambuc.\"
7ebfedea0SLionel Sambuc.\" Redistribution and use in source and binary forms, with or without
8ebfedea0SLionel Sambuc.\" modification, are permitted provided that the following conditions
9ebfedea0SLionel Sambuc.\" are met:
10ebfedea0SLionel Sambuc.\"
11ebfedea0SLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright
12ebfedea0SLionel Sambuc.\"    notice, this list of conditions and the following disclaimer.
13ebfedea0SLionel Sambuc.\"
14ebfedea0SLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright
15ebfedea0SLionel Sambuc.\"    notice, this list of conditions and the following disclaimer in the
16ebfedea0SLionel Sambuc.\"    documentation and/or other materials provided with the distribution.
17ebfedea0SLionel Sambuc.\"
18ebfedea0SLionel Sambuc.\" 3. Neither the name of the Institute nor the names of its contributors
19ebfedea0SLionel Sambuc.\"    may be used to endorse or promote products derived from this software
20ebfedea0SLionel Sambuc.\"    without specific prior written permission.
21ebfedea0SLionel Sambuc.\"
22ebfedea0SLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23ebfedea0SLionel Sambuc.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24ebfedea0SLionel Sambuc.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25ebfedea0SLionel Sambuc.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26ebfedea0SLionel Sambuc.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27ebfedea0SLionel Sambuc.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28ebfedea0SLionel Sambuc.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29ebfedea0SLionel Sambuc.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30ebfedea0SLionel Sambuc.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31ebfedea0SLionel Sambuc.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32ebfedea0SLionel Sambuc.\" SUCH DAMAGE.
33ebfedea0SLionel Sambuc.\" Id
34ebfedea0SLionel Sambuc.\"
35ebfedea0SLionel Sambuc.Dd August 14, 2003
36ebfedea0SLionel Sambuc.Dt ECALLOC 3
37ebfedea0SLionel Sambuc.Os
38ebfedea0SLionel Sambuc.Sh NAME
39ebfedea0SLionel Sambuc.Nm ecalloc ,
40ebfedea0SLionel Sambuc.Nm emalloc ,
41ebfedea0SLionel Sambuc.Nm eread ,
42ebfedea0SLionel Sambuc.Nm erealloc ,
43ebfedea0SLionel Sambuc.Nm esetenv ,
44ebfedea0SLionel Sambuc.Nm estrdup ,
45ebfedea0SLionel Sambuc.Nm ewrite
46ebfedea0SLionel Sambuc.Nd exit-on-failure wrapper functions
47ebfedea0SLionel Sambuc.Sh LIBRARY
48ebfedea0SLionel SambucThe roken library (libroken, -lroken)
49ebfedea0SLionel Sambuc.Sh SYNOPSIS
50ebfedea0SLionel Sambuc.Fd #include <roken.h>
51ebfedea0SLionel Sambuc.Ft "void *"
52ebfedea0SLionel Sambuc.Fn ecalloc "size_t number" "size_t size"
53ebfedea0SLionel Sambuc.Ft "void *"
54ebfedea0SLionel Sambuc.Fn emalloc "size_t sz"
55ebfedea0SLionel Sambuc.Ft ssize_t
56ebfedea0SLionel Sambuc.Fn eread "int fd" "void *buf" "size_t nbytes"
57ebfedea0SLionel Sambuc.Ft "void *"
58ebfedea0SLionel Sambuc.Fn erealloc "void *ptr" "size_t sz"
59ebfedea0SLionel Sambuc.Ft void
60ebfedea0SLionel Sambuc.Fn esetenv "const char *var" "const char *val" "int rewrite"
61ebfedea0SLionel Sambuc.Ft "char *"
62ebfedea0SLionel Sambuc.Fn estrdup "const char *str"
63ebfedea0SLionel Sambuc.Ft ssize_t
64ebfedea0SLionel Sambuc.Fn ewrite "int fd" "const void *buf" "size_t nbytes"
65ebfedea0SLionel Sambuc.Sh DESCRIPTION
66ebfedea0SLionel SambucThese functions do the same as the ones without the
67ebfedea0SLionel Sambuc.Dq e
68ebfedea0SLionel Sambucprefix, but if there is an error they will print a message with
69ebfedea0SLionel Sambuc.Xr errx 3 ,
70ebfedea0SLionel Sambucand exit. For
71ebfedea0SLionel Sambuc.Nm eread
72ebfedea0SLionel Sambucand
73ebfedea0SLionel Sambuc.Nm ewrite
74ebfedea0SLionel Sambucthis is also true for partial data.
75ebfedea0SLionel Sambuc.Pp
76ebfedea0SLionel SambucThis is useful in applications when there is no need for a more
77ebfedea0SLionel Sambucadvanced failure mode.
78ebfedea0SLionel Sambuc.Sh SEE ALSO
79ebfedea0SLionel Sambuc.Xr read 2 ,
80ebfedea0SLionel Sambuc.Xr write 2 ,
81ebfedea0SLionel Sambuc.Xr calloc 3 ,
82ebfedea0SLionel Sambuc.Xr errx 3 ,
83ebfedea0SLionel Sambuc.Xr malloc 3 ,
84ebfedea0SLionel Sambuc.Xr realloc 3 ,
85ebfedea0SLionel Sambuc.Xr setenv 3 ,
86ebfedea0SLionel Sambuc.Xr strdup 3
87