[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/lib xalloc.h,1.1.1.1,1.2
From: |
karl |
Subject: |
texinfo/lib xalloc.h,1.1.1.1,1.2 |
Date: |
Fri, 20 Feb 2004 14:34:30 +0100 |
Update of /cvsroot/texinfo/texinfo/lib
In directory sheep:/tmp/cvs-serv6624
Modified Files:
xalloc.h
Log Message:
gnulib
Index: xalloc.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/lib/xalloc.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** xalloc.h 6 Dec 2003 01:33:18 -0000 1.1.1.1
--- xalloc.h 20 Feb 2004 13:34:28 -0000 1.2
***************
*** 55,60 ****
--- 55,77 ----
void *xrealloc (void *p, size_t s);
void *xnrealloc (void *p, size_t n, size_t s);
+ void *x2realloc (void *p, size_t *pn);
+ void *x2nrealloc (void *p, size_t *pn, size_t s);
void *xclone (void const *p, size_t s);
char *xstrdup (const char *str);
+
+ /* Return 1 if an array of N objects, each of size S, cannot exist due
+ to size arithmetic overflow. S must be positive and N must be
+ nonnegative. This is a macro, not an inline function, so that it
+ works correctly even when SIZE_MAX < N.
+
+ By gnulib convention, SIZE_MAX represents overflow in size
+ calculations, so the conservative dividend to use here is
+ SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
+ However, malloc (SIZE_MAX) fails on all known hosts where
+ sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
+ exactly-SIZE_MAX allocations on such hosts; this avoids a test and
+ branch when S is known to be 1. */
+ # define xalloc_oversized(n, s) \
+ ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
/* These macros are deprecated; they will go away soon, and are retained
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/lib xalloc.h,1.1.1.1,1.2,
karl <=