diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-19 21:27:12 (GMT) |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-19 21:27:12 (GMT) |
commit | 26fbe7f1e68bb0c96da32491efcf3696fe6c299b (patch) | |
tree | c4d95289187a64e9c7517bf73d8208026c3d2fb3 /gl/xmalloc.c | |
parent | 5f79e3e9f62ca5487d9881973149136ba1d19d3e (diff) | |
download | monitoring-plugins-26fbe7f1e68bb0c96da32491efcf3696fe6c299b.tar.gz |
Sync with the latest Gnulib code (6f2d632)
Diffstat (limited to 'gl/xmalloc.c')
-rw-r--r-- | gl/xmalloc.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gl/xmalloc.c b/gl/xmalloc.c index ecce529..57e34b7 100644 --- a/gl/xmalloc.c +++ b/gl/xmalloc.c | |||
@@ -1,8 +1,6 @@ | |||
1 | /* xmalloc.c -- malloc with out of memory checking | 1 | /* xmalloc.c -- malloc with out of memory checking |
2 | 2 | ||
3 | Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | 3 | Copyright (C) 1990-2000, 2002-2006, 2008-2013 Free Software Foundation, Inc. |
4 | 2000, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free Software | ||
5 | Foundation, Inc. | ||
6 | 4 | ||
7 | This program is free software: you can redistribute it and/or modify | 5 | This program is free software: you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
@@ -19,19 +17,17 @@ | |||
19 | 17 | ||
20 | #include <config.h> | 18 | #include <config.h> |
21 | 19 | ||
22 | #if ! HAVE_INLINE | 20 | #define XALLOC_INLINE _GL_EXTERN_INLINE |
23 | # define static_inline | 21 | |
24 | #endif | ||
25 | #include "xalloc.h" | 22 | #include "xalloc.h" |
26 | #undef static_inline | ||
27 | 23 | ||
28 | #include <stdlib.h> | 24 | #include <stdlib.h> |
29 | #include <string.h> | 25 | #include <string.h> |
30 | 26 | ||
31 | /* 1 if calloc is known to be compatible with GNU calloc. This | 27 | /* 1 if calloc is known to be compatible with GNU calloc. This |
32 | matters if we are not also using the calloc module, which defines | 28 | matters if we are not also using the calloc module, which defines |
33 | HAVE_CALLOC and supports the GNU API even on non-GNU platforms. */ | 29 | HAVE_CALLOC_GNU and supports the GNU API even on non-GNU platforms. */ |
34 | #if defined HAVE_CALLOC || defined __GLIBC__ | 30 | #if defined HAVE_CALLOC_GNU || (defined __GLIBC__ && !defined __UCLIBC__) |
35 | enum { HAVE_GNU_CALLOC = 1 }; | 31 | enum { HAVE_GNU_CALLOC = 1 }; |
36 | #else | 32 | #else |
37 | enum { HAVE_GNU_CALLOC = 0 }; | 33 | enum { HAVE_GNU_CALLOC = 0 }; |
@@ -54,8 +50,16 @@ xmalloc (size_t n) | |||
54 | void * | 50 | void * |
55 | xrealloc (void *p, size_t n) | 51 | xrealloc (void *p, size_t n) |
56 | { | 52 | { |
53 | if (!n && p) | ||
54 | { | ||
55 | /* The GNU and C99 realloc behaviors disagree here. Act like | ||
56 | GNU, even if the underlying realloc is C99. */ | ||
57 | free (p); | ||
58 | return NULL; | ||
59 | } | ||
60 | |||
57 | p = realloc (p, n); | 61 | p = realloc (p, n); |
58 | if (!p && n != 0) | 62 | if (!p && n) |
59 | xalloc_die (); | 63 | xalloc_die (); |
60 | return p; | 64 | return p; |
61 | } | 65 | } |