xref: /openbsd-src/usr.bin/cvs/xmalloc.h (revision 397ddb8a3f80a7c0fc96b9834bf9a6841845ed3c)
1*397ddb8aSnicm /* $OpenBSD: xmalloc.h,v 1.5 2015/11/05 09:48:21 nicm Exp $ */
20450b43bSjoris 
30450b43bSjoris /*
40450b43bSjoris  * Author: Tatu Ylonen <ylo@cs.hut.fi>
50450b43bSjoris  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
60450b43bSjoris  *                    All rights reserved
70450b43bSjoris  * Created: Mon Mar 20 22:09:17 1995 ylo
80450b43bSjoris  *
92e0e138cSray  * Versions of malloc and friends that check their results, and never return
100450b43bSjoris  * failure (they call fatal if they encounter an error).
110450b43bSjoris  *
120450b43bSjoris  * As far as I am concerned, the code I have written for this software
130450b43bSjoris  * can be used freely for any purpose.  Any derived versions of this
140450b43bSjoris  * software must be clearly marked as such, and if the derived work is
150450b43bSjoris  * incompatible with the protocol description in the RFC file, it must be
160450b43bSjoris  * called by a name other than "ssh" or "Secure Shell".
170450b43bSjoris  */
180450b43bSjoris 
190450b43bSjoris #ifndef XMALLOC_H
200450b43bSjoris #define XMALLOC_H
210450b43bSjoris 
220450b43bSjoris void	*xmalloc(size_t);
232e0e138cSray void	*xcalloc(size_t, size_t);
24caa2ffb0Sderaadt void	*xreallocarray(void *, size_t, size_t);
250450b43bSjoris char	*xstrdup(const char *);
262e0e138cSray int	 xasprintf(char **, const char *, ...)
272e0e138cSray                 __attribute__((__format__ (printf, 2, 3)))
282e0e138cSray                 __attribute__((__nonnull__ (2)));
29005d0989Sxsa int	 xsnprintf(char *, size_t, const char *, ...)
30005d0989Sxsa 		__attribute__((__format__ (printf, 3, 4)))
31005d0989Sxsa 		__attribute__((__nonnull__ (3)))
32005d0989Sxsa 		__attribute__((__bounded__ (__string__,1,2)));
330450b43bSjoris 
340450b43bSjoris #endif	/* XMALLOC_H */
35