Blame


1 dd038bc6 2021-09-21 thomas.ad /* $OpenBSD$ */
2 dd038bc6 2021-09-21 thomas.ad
3 dd038bc6 2021-09-21 thomas.ad /*
4 dd038bc6 2021-09-21 thomas.ad * Author: Tatu Ylonen <ylo@cs.hut.fi>
5 dd038bc6 2021-09-21 thomas.ad * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
6 dd038bc6 2021-09-21 thomas.ad * All rights reserved
7 dd038bc6 2021-09-21 thomas.ad * Created: Mon Mar 20 22:09:17 1995 ylo
8 dd038bc6 2021-09-21 thomas.ad *
9 dd038bc6 2021-09-21 thomas.ad * Versions of malloc and friends that check their results, and never return
10 dd038bc6 2021-09-21 thomas.ad * failure (they call fatal if they encounter an error).
11 dd038bc6 2021-09-21 thomas.ad *
12 dd038bc6 2021-09-21 thomas.ad * As far as I am concerned, the code I have written for this software
13 dd038bc6 2021-09-21 thomas.ad * can be used freely for any purpose. Any derived versions of this
14 dd038bc6 2021-09-21 thomas.ad * software must be clearly marked as such, and if the derived work is
15 dd038bc6 2021-09-21 thomas.ad * incompatible with the protocol description in the RFC file, it must be
16 dd038bc6 2021-09-21 thomas.ad * called by a name other than "ssh" or "Secure Shell".
17 dd038bc6 2021-09-21 thomas.ad */
18 dd038bc6 2021-09-21 thomas.ad
19 dd038bc6 2021-09-21 thomas.ad #ifndef XMALLOC_H
20 dd038bc6 2021-09-21 thomas.ad #define XMALLOC_H
21 dd038bc6 2021-09-21 thomas.ad
22 dd038bc6 2021-09-21 thomas.ad #include <stdarg.h>
23 dd038bc6 2021-09-21 thomas.ad
24 dd038bc6 2021-09-21 thomas.ad #if !defined(__bounded__)
25 dd038bc6 2021-09-21 thomas.ad #define __bounded__(x, y, z)
26 dd038bc6 2021-09-21 thomas.ad #endif
27 dd038bc6 2021-09-21 thomas.ad
28 dd038bc6 2021-09-21 thomas.ad void *xmalloc(size_t);
29 dd038bc6 2021-09-21 thomas.ad void *xcalloc(size_t, size_t);
30 dd038bc6 2021-09-21 thomas.ad void *xrealloc(void *, size_t);
31 dd038bc6 2021-09-21 thomas.ad void *xreallocarray(void *, size_t, size_t);
32 dd038bc6 2021-09-21 thomas.ad void *xrecallocarray(void *, size_t, size_t, size_t);
33 dd038bc6 2021-09-21 thomas.ad char *xstrdup(const char *);
34 dd038bc6 2021-09-21 thomas.ad char *xstrndup(const char *, size_t);
35 dd038bc6 2021-09-21 thomas.ad int xasprintf(char **, const char *, ...)
36 dd038bc6 2021-09-21 thomas.ad __attribute__((__format__ (printf, 2, 3)))
37 dd038bc6 2021-09-21 thomas.ad __attribute__((__nonnull__ (2)));
38 dd038bc6 2021-09-21 thomas.ad int xvasprintf(char **, const char *, va_list)
39 dd038bc6 2021-09-21 thomas.ad __attribute__((__nonnull__ (2)));
40 dd038bc6 2021-09-21 thomas.ad int xsnprintf(char *, size_t, const char *, ...)
41 dd038bc6 2021-09-21 thomas.ad __attribute__((__format__ (printf, 3, 4)))
42 dd038bc6 2021-09-21 thomas.ad __attribute__((__nonnull__ (3)))
43 dd038bc6 2021-09-21 thomas.ad __attribute__((__bounded__ (__string__, 1, 2)));
44 dd038bc6 2021-09-21 thomas.ad int xvsnprintf(char *, size_t, const char *, va_list)
45 dd038bc6 2021-09-21 thomas.ad __attribute__((__nonnull__ (3)))
46 dd038bc6 2021-09-21 thomas.ad __attribute__((__bounded__ (__string__, 1, 2)));
47 dd038bc6 2021-09-21 thomas.ad
48 dd038bc6 2021-09-21 thomas.ad #endif /* XMALLOC_H */