From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20257 invoked by alias); 18 Oct 2009 16:14:27 -0000 Received: (qmail 20244 invoked by uid 22791); 18 Oct 2009 16:14:26 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Oct 2009 16:14:23 +0000 Received: from jupiter.vmware.com (mailhost5.vmware.com [10.16.68.131]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id BAA9C5602E; Sun, 18 Oct 2009 09:14:21 -0700 (PDT) Received: from [10.20.94.141] (msnyder-server.eng.vmware.com [10.20.94.141]) by jupiter.vmware.com (Postfix) with ESMTP id AB266DC05F; Sun, 18 Oct 2009 09:14:21 -0700 (PDT) Message-ID: <4ADB3D7B.4000600@vmware.com> Date: Sun, 18 Oct 2009 16:14:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: Joel Brobecker CC: Hui Zhu , "gdb-patches@sourceware.org" Subject: Re: [RFA] record.c - save some memory in record log. References: <4AD761AD.40307@vmware.com> <20091015191656.GF5272@adacore.com> <20091018161019.GM5272@adacore.com> In-Reply-To: <20091018161019.GM5272@adacore.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-10/txt/msg00416.txt.bz2 Joel Brobecker wrote: >> But I think: > > Note that I was just idly mentioning a trick I saw us use in the past, > but it's definitely ok if you guys think it's a bad idea. > >> + union >> + { >> + gdb_byte *ptr; >> + gdb_byte buf[2 * sizeof (gdb_byte *)]; >> >> Make the size of buf more clear. > > The problem with this approach is that the size of the union is the > maximum of all its components. So the size of your union is always > going to be 8/16 bytes, depending on whether addresses are 4 or 8 bytes. > Unless buf was meant to be a 2-bytes buffer, then the size is always > going to be 4 bytes. > > With the trick I provided, the size is always going to be exactly as > much as you need. But, like I said, it's not exactly super clean... > Joel, it's a work in progress. ;-) I see the change I made as having made the data structure incrementally better. There's always room for a further change that makes it better still.