From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NEaSJ-0002n3-N5 for mharc-grub-devel@gnu.org; Sat, 28 Nov 2009 22:28:11 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NEaSI-0002my-0J for grub-devel@gnu.org; Sat, 28 Nov 2009 22:28:10 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NEaSD-0002jz-4W for grub-devel@gnu.org; Sat, 28 Nov 2009 22:28:09 -0500 Received: from [199.232.76.173] (port=58537 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NEaSC-0002jw-Vz for grub-devel@gnu.org; Sat, 28 Nov 2009 22:28:05 -0500 Received: from xvm-190-8.ghst.net ([217.70.190.8]:54152 helo=aybabtu.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NEaSC-0002lM-K4 for grub-devel@gnu.org; Sat, 28 Nov 2009 22:28:04 -0500 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtp (Exim 4.69) (envelope-from ) id 1NEaSA-0002Mq-DU for grub-devel@gnu.org; Sun, 29 Nov 2009 04:28:02 +0100 Received: from rmh by thorin with local (Exim 4.69) (envelope-from ) id 1NEaS9-0000cb-LM for grub-devel@gnu.org; Sun, 29 Nov 2009 04:28:01 +0100 Date: Sun, 29 Nov 2009 04:28:01 +0100 From: Robert Millan To: The development of GNU GRUB Message-ID: <20091129032801.GA2329@thorin> References: <20091129004950.GA7856@pina.cat> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20091129004950.GA7856@pina.cat> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: gettext.c patch: reuse memory X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Nov 2009 03:28:10 -0000 On Sun, Nov 29, 2009 at 12:49:50AM +0000, Carles Pina i Estany wrote: > > Hello, > > This week I realised of a quite big mistake in the gettext module. Every > time that the user of this module was asking for string translation, > gettext module was allocating new memory and returning it. So if the > user was asking 10 times for the same string, gettext was creating 10 > new strings and leaking memory. > > With the attached patch, gettext module saves in a list the > translations. So if a user asks again for the same translation it > returns the same pointer to the already allocated string instead of a > new one. > > If someone wants to discuss things maybe in the IRC is better (but feel > free to talk it here too). There are different approaches, and the > current one is not perfect but I don't see any perfect design. How does GNU gettext handle this? I suspect it could be simpler. For example, is it practical to allocate a big chunk of memory for the whole .mo, then return pointers to it? -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."