From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18227 invoked by alias); 26 Jun 2004 03:04:41 -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 17824 invoked from network); 26 Jun 2004 03:04:34 -0000 Received: from unknown (HELO develer.com) (151.38.19.110) by sourceware.org with SMTP; 26 Jun 2004 03:04:34 -0000 Received: (qmail 1882 invoked from network); 26 Jun 2004 03:04:17 -0000 Received: from beetle.trilan (HELO ?10.3.2.254?) (?JeNK4aKr3RkZBNyC77MwSTt+tPH9B3Wu?@10.3.2.254) by trinity.trilan with SMTP; 26 Jun 2004 03:04:17 -0000 Message-ID: <40DCE7B0.5000203@develer.com> Date: Sat, 26 Jun 2004 03:04:00 -0000 From: Bernardo Innocenti Organization: Develer S.r.l. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040622 MIME-Version: 1.0 To: Daniel Jacobowitz CC: 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 References: <40DCC86A.4010306@develer.com> <40DCD0EE.9010208@develer.com> <40DCE1C8.4020202@develer.com> <20040626024617.GA31620@nevyn.them.org> In-Reply-To: <20040626024617.GA31620@nevyn.them.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2004-06/txt/msg00549.txt.bz2 Daniel Jacobowitz wrote: > On Sat, Jun 26, 2004 at 04:39:04AM +0200, Bernardo Innocenti wrote: > >>Ian Lance Taylor wrote: >> >>>Bernardo Innocenti writes: >>> >>> >>> >>>>On second thought, the interface for xrenew() or xresize() wasn't >>>>even usable without a size argument. >>> >>>Oh yeah. >>> >>> >>> >>>>Maybe this would be better? >>>> >>>> #define xrenewvec(P, T, N) (T *) xrealloc ((P), sizeof(T) * (N)) >>> >>> >>>No, people use realloc with variable size arrays at the end of >>>structs. xrenewvec (or xresizevec) is a good idea, but you still need >>>xrenew (or xresize). > > > Bernando, you've now got an interface which allows reallocating to a > variable size, but not allocating to one... There's no need for a > rush, let's give people some time to comment before putting this into > libiberty. As DJ says, it's hard to take things out of libiberty. I've not yet committed anything, but I see your point. There's good symmetry here: struct foo *v = xnewvec (struct foo, 42); v = xresizevec (struct foo, v, 666); xdeletevec (v); But not here: struct varsize *s = ??? s = xresize (struct varsize, s, sizeof (struct varsize) + strlen (name)); xdelete (s); Maybe we should add this: #define xvarnew(T, S) (T *) xmalloc (S) Another possibility would be dropping this realloc interface altogether and sticking with a simpler interface that has the same limitations of C++. -- // Bernardo Innocenti - Develer S.r.l., R&D dept. \X/ http://www.develer.com/