From: Robert Millan <rmh@aybabtu.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: gettext.c patch: reuse memory
Date: Sun, 29 Nov 2009 04:28:01 +0100 [thread overview]
Message-ID: <20091129032801.GA2329@thorin> (raw)
In-Reply-To: <20091129004950.GA7856@pina.cat>
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."
next prev parent reply other threads:[~2009-11-29 3:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-29 0:49 gettext.c patch: reuse memory Carles Pina i Estany
2009-11-29 3:28 ` Robert Millan [this message]
2009-11-29 9:36 ` Carles Pina i Estany
2009-11-29 10:36 ` Carles Pina i Estany
2009-11-29 18:36 ` Carles Pina i Estany
2009-11-29 19:40 ` Carles Pina i Estany
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091129032801.GA2329@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.