From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30905 invoked by alias); 28 Jun 2004 18:52:38 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 30830 invoked from network); 28 Jun 2004 18:52:37 -0000 Received: from unknown (HELO lon-mail-1.gradwell.net) (193.111.201.125) by sourceware.org with SMTP; 28 Jun 2004 18:52:37 -0000 Received: (qmail 35332 invoked from network); 28 Jun 2004 18:52:36 -0000 Received: from digraph.polyomino.org.uk (postmaster%pop3.polyomino.org.uk@81.187.227.50) by lon-mail-1.gradwell.net with SMTP; 28 Jun 2004 18:52:36 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.34) id 1Bf1F5-0003ww-Vm; Mon, 28 Jun 2004 18:52:35 +0000 Date: Mon, 28 Jun 2004 18:52:00 -0000 From: "Joseph S. Myers" X-X-Sender: jsm28@digraph.polyomino.org.uk To: Bernardo Innocenti cc: Andrew Cagney , Daniel Jacobowitz , Ian Lance Taylor , GCC Patches , gdb-patches@sources.redhat.com, binutils@sources.redhat.com, DJ Delorie Subject: Re: [top-level] C++-friendly allocators for libiberty In-Reply-To: <40E06174.9020203@develer.com> Message-ID: References: <40DCC86A.4010306@develer.com> <40DCD0EE.9010208@develer.com> <40DCE1C8.4020202@develer.com> <20040626024617.GA31620@nevyn.them.org> <40DDB0B7.1040902@gnu.org> <40DE5CC0.7070102@develer.com> <40E03CB7.1060500@gnu.org> <40E06174.9020203@develer.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2004-06/txt/msg00649.txt.bz2 On Mon, 28 Jun 2004, Bernardo Innocenti wrote: > Andrew Cagney wrote: > >>Andrew Cagney wrote: > >>Hmmm... What's the advantage of using XZALLOC over XCALLOC? > > > > It avoids that extra argument (but yes, XZALLOC should be implemented > > using XCALLOC). > > Yes, I've always hated the few C library functions with size/number > of elements pair, as if the caller couldn't do multiplications. > (fread() and fwrite() come to mind.) While I generally agree with this view of such functions (fread and fwrite are worse than calloc, as if the item size isn't 1 you cannot use them reliably in the presence of possible interrupts by signals), they do at least if properly implemented check for integer overflow in the multiplication. See glibc's calloc for how to avoid a division in most cases in this check, and gnulib's xalloc.h for optimizing the case where the element size is a constant. -- Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/ jsm@polyomino.org.uk (personal mail) jsm28@gcc.gnu.org (Bugzilla assignments and CCs)