diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-01-15 04:22:57 -0500 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-01-15 05:19:08 -0500 |
commit | 71cdb52799220f8d9052643baf1d3e9836a9c755 (patch) | |
tree | 27aee97a35d9ab51f0d8f64a46690bd41a5f8c1b /gl/xalloc.h | |
parent | f7afa46586645e50498d8b2d0c67884f014dc3a4 (diff) | |
download | monitoring-plugins-71cdb52799220f8d9052643baf1d3e9836a9c755.tar.gz |
Sync with gnulib
Diffstat (limited to 'gl/xalloc.h')
-rw-r--r-- | gl/xalloc.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gl/xalloc.h b/gl/xalloc.h index 40dcf4bd..57a13e0a 100644 --- a/gl/xalloc.h +++ b/gl/xalloc.h | |||
@@ -37,6 +37,14 @@ extern "C" { | |||
37 | # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) | 37 | # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) |
38 | # endif | 38 | # endif |
39 | 39 | ||
40 | # ifndef ATTRIBUTE_MALLOC | ||
41 | # if __GNUC__ >= 3 | ||
42 | # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) | ||
43 | # else | ||
44 | # define ATTRIBUTE_MALLOC | ||
45 | # endif | ||
46 | # endif | ||
47 | |||
40 | /* This function is always triggered when memory is exhausted. | 48 | /* This function is always triggered when memory is exhausted. |
41 | It must be defined by the application, either explicitly | 49 | It must be defined by the application, either explicitly |
42 | or by using gnulib's xalloc-die module. This is the | 50 | or by using gnulib's xalloc-die module. This is the |
@@ -44,13 +52,13 @@ extern "C" { | |||
44 | memory allocation failure. */ | 52 | memory allocation failure. */ |
45 | extern void xalloc_die (void) ATTRIBUTE_NORETURN; | 53 | extern void xalloc_die (void) ATTRIBUTE_NORETURN; |
46 | 54 | ||
47 | void *xmalloc (size_t s); | 55 | void *xmalloc (size_t s) ATTRIBUTE_MALLOC; |
48 | void *xzalloc (size_t s); | 56 | void *xzalloc (size_t s) ATTRIBUTE_MALLOC; |
49 | void *xcalloc (size_t n, size_t s); | 57 | void *xcalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; |
50 | void *xrealloc (void *p, size_t s); | 58 | void *xrealloc (void *p, size_t s); |
51 | void *x2realloc (void *p, size_t *pn); | 59 | void *x2realloc (void *p, size_t *pn); |
52 | void *xmemdup (void const *p, size_t s); | 60 | void *xmemdup (void const *p, size_t s) ATTRIBUTE_MALLOC; |
53 | char *xstrdup (char const *str); | 61 | char *xstrdup (char const *str) ATTRIBUTE_MALLOC; |
54 | 62 | ||
55 | /* Return 1 if an array of N objects, each of size S, cannot exist due | 63 | /* Return 1 if an array of N objects, each of size S, cannot exist due |
56 | to size arithmetic overflow. S must be positive and N must be | 64 | to size arithmetic overflow. S must be positive and N must be |
@@ -97,10 +105,10 @@ char *xstrdup (char const *str); | |||
97 | # if HAVE_INLINE | 105 | # if HAVE_INLINE |
98 | # define static_inline static inline | 106 | # define static_inline static inline |
99 | # else | 107 | # else |
100 | void *xnmalloc (size_t n, size_t s); | 108 | void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; |
101 | void *xnrealloc (void *p, size_t n, size_t s); | 109 | void *xnrealloc (void *p, size_t n, size_t s); |
102 | void *x2nrealloc (void *p, size_t *pn, size_t s); | 110 | void *x2nrealloc (void *p, size_t *pn, size_t s); |
103 | char *xcharalloc (size_t n); | 111 | char *xcharalloc (size_t n) ATTRIBUTE_MALLOC; |
104 | # endif | 112 | # endif |
105 | 113 | ||
106 | # ifdef static_inline | 114 | # ifdef static_inline |
@@ -108,6 +116,7 @@ char *xstrdup (char const *str); | |||
108 | /* Allocate an array of N objects, each with S bytes of memory, | 116 | /* Allocate an array of N objects, each with S bytes of memory, |
109 | dynamically, with error checking. S must be nonzero. */ | 117 | dynamically, with error checking. S must be nonzero. */ |
110 | 118 | ||
119 | static_inline void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; | ||
111 | static_inline void * | 120 | static_inline void * |
112 | xnmalloc (size_t n, size_t s) | 121 | xnmalloc (size_t n, size_t s) |
113 | { | 122 | { |
@@ -219,6 +228,7 @@ x2nrealloc (void *p, size_t *pn, size_t s) | |||
219 | /* Return a pointer to a new buffer of N bytes. This is like xmalloc, | 228 | /* Return a pointer to a new buffer of N bytes. This is like xmalloc, |
220 | except it returns char *. */ | 229 | except it returns char *. */ |
221 | 230 | ||
231 | static_inline char *xcharalloc (size_t n) ATTRIBUTE_MALLOC; | ||
222 | static_inline char * | 232 | static_inline char * |
223 | xcharalloc (size_t n) | 233 | xcharalloc (size_t n) |
224 | { | 234 | { |