exit.h is replaced with stdlib.h.
[gnulib.git] / lib / calloc.c
index 59c65f0..c8b1e1e 100644 (file)
@@ -1,6 +1,6 @@
 /* calloc() function that is glibc compatible.
    This wrapper function is required at least on Tru64 UNIX 5.1.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,9 +18,7 @@
 
 /* written by Jim Meyering */
 
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include <config.h>
 #undef calloc
 
 #include <stdlib.h>
@@ -32,10 +30,9 @@ void *
 rpl_calloc (size_t n, size_t s)
 {
   size_t bytes;
-  if (n == 0)
-    n = 1;
-  if (s == 0)
-    s = 1;
+
+  if (n == 0 || s == 0)
+    return calloc (1, 1);
 
   /* Defend against buggy calloc implementations that mishandle
      size_t overflow.  */