bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Translation-i18n] Memory management in gettext?


From: Bruno Haible
Subject: Re: [Translation-i18n] Memory management in gettext?
Date: Sun, 12 Sep 2010 23:19:45 +0200
User-agent: KMail/1.9.9

Hi Chris,

bug-gnu-gettext is a slightly better mailing list for this type of question;
I'm adding it in CC.

Chris Scaife asked:
> Documentation for functions like dngettext state that translated
> strings are statically allocated. However if I were to keep opening
> new domains surely it would run out of space?

No, it won't run out of space. "statically allocated" here means allocated
with indefinite extent. If you keep passing new domains to dgettext, dcgettext,
the MO files will be loaded and transformed to "statically allocated" memory.

> Please can someone help me understand how that static allocation works
> so that I can make sure I'm not accidentally using strings that have
> been discarded from memory.

If gettext(s) != s, you are guaranteed that gettext(s) is statically allocated,
that is, you can access it as long as you want, and it will not be discarded
from memory. Of course, if gettext(s) == s, then it depends on how the caller
has allocated s and will free s.

Bruno



reply via email to

[Prev in Thread] Current Thread [Next in Thread]