summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-03-15 17:30:11 +0100
committerIvan Maidanski <ivmai@mail.ru>2012-03-15 17:41:40 +0100
commitd84a74457c8e60f553e0b24ae4bfef3bc7752884 (patch)
tree9c9559d7cf4e9e035c330caa1011e8e550ed2027
parent62d1696b552e679e79769459222478ed6193e9b1 (diff)
Fix calloc-related code to prevent SIZE_MAX redefinition in sys headers
* malloc.c: Include limits.h for SIZE_MAX. * malloc.c (SIZE_MAX, calloc): Define GC_SIZE_MAX instead of SIZE_MAX.
-rw-r--r--malloc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/malloc.c b/malloc.c
index 6ef1094..e99e306 100644
--- a/malloc.c
+++ b/malloc.c
@@ -371,12 +371,16 @@ void * malloc(size_t lb)
}
#endif /* GC_LINUX_THREADS */
-#ifndef SIZE_MAX
-#define SIZE_MAX (~(size_t)0)
+#include <limits.h>
+#ifdef SIZE_MAX
+# define GC_SIZE_MAX SIZE_MAX
+#else
+# define GC_SIZE_MAX (~(size_t)0)
#endif
+
void * calloc(size_t n, size_t lb)
{
- if (lb && n > SIZE_MAX / lb)
+ if (lb && n > GC_SIZE_MAX / lb)
return NULL;
# if defined(GC_LINUX_THREADS) /* && !defined(USE_PROC_FOR_LIBRARIES) */
/* libpthread allocated some memory that is only pointed to by */