[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gettext.c patch: reuse memory
From: |
Robert Millan |
Subject: |
Re: gettext.c patch: reuse memory |
Date: |
Sun, 29 Nov 2009 04:28:01 +0100 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
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."