From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19010 invoked by alias); 18 Oct 2009 16:10:31 -0000 Received: (qmail 19000 invoked by uid 22791); 18 Oct 2009 16:10:30 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Oct 2009 16:10:25 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 57D6B2BAC06; Sun, 18 Oct 2009 12:10:24 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id El4MWtScXe7X; Sun, 18 Oct 2009 12:10:24 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 1EC472BAC01; Sun, 18 Oct 2009 12:10:24 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 36062F5921; Sun, 18 Oct 2009 09:10:20 -0700 (PDT) Date: Sun, 18 Oct 2009 16:10:00 -0000 From: Joel Brobecker To: Hui Zhu Cc: Michael Snyder , "gdb-patches@sourceware.org" Subject: Re: [RFA] record.c - save some memory in record log. Message-ID: <20091018161019.GM5272@adacore.com> References: <4AD761AD.40307@vmware.com> <20091015191656.GF5272@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) 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/msg00414.txt.bz2 > 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