bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] xmalloc, xnmalloc


From: Bruno Haible
Subject: Re: [bug-gnulib] xmalloc, xnmalloc
Date: Tue, 7 Nov 2006 14:47:37 +0100
User-agent: KMail/1.9.1

Hi Paul,

In case HAVE_INLINE is not defined, xnmalloc is not an inline function.
XNMALLOC (n, char) was optimized to a single xmalloc call. Can we restore
this optimization?

2006-11-06  Bruno Haible  <address@hidden>

        * lib/xalloc.h (XNMALLOC): Restore optimization of sizeof(T) = 1 case.

*** gnulib-20061106/lib/xalloc.h        2006-11-07 03:13:57.000000000 +0100
--- gnulib-20061106-modified/lib/xalloc.h       2006-11-07 03:30:02.000000000 
+0100
***************
*** 149,155 ****
  
  /* Allocate memory for N elements of type T, with error checking.  */
  /* extern t *XNMALLOC (size_t n, typename t); */
! #define XNMALLOC(n, t) ((t *) xnmalloc (n, sizeof (t)))
  
  /* Allocate an object of type T dynamically, with error checking,
     and zero it.  */
--- 149,156 ----
  
  /* Allocate memory for N elements of type T, with error checking.  */
  /* extern t *XNMALLOC (size_t n, typename t); */
! #define XNMALLOC(n, t) \
!   ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
  
  /* Allocate an object of type T dynamically, with error checking,
     and zero it.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]