[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
calloc.c nit
From: |
Jim Meyering |
Subject: |
calloc.c nit |
Date: |
Thu, 16 Jun 2005 16:51:27 +0200 |
I've just checked in this change
to make the code agree with this comment:
/* Allocate and zero-fill an NxS-byte block of memory from the heap.
If N or S is zero, allocate and zero-fill a 1-byte block. */
2005-06-16 Jim Meyering <address@hidden>
* calloc.c (rpl_calloc): Allocate a 1-byte buffer (not 1xS or Nx1)
when either N or S is zero.
Index: lib/calloc.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/calloc.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -p -u -r1.3 -r1.4
--- lib/calloc.c 14 May 2005 06:03:57 -0000 1.3
+++ lib/calloc.c 16 Jun 2005 14:49:03 -0000 1.4
@@ -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 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
@@ -32,10 +32,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. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- calloc.c nit,
Jim Meyering <=