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: Chris Scaife
Subject: Re: [Translation-i18n] Memory management in gettext?
Date: Tue, 14 Sep 2010 13:55:46 +1200

Thanks for this information!

I am pleased that the strings will remain on hand and I don't have to
worry about copying them into other containers. It is also very handy
to be able to test if a translation took place by simply checking the
return value for identity with the original string provided. I get the
impression the whole gettext thing was really well designed from the
start :)

In my project I wanted to differentiate on negative values for
ngettext and dngettext pluralization. Sadly they only work with
unsigned long integers. Part of the problem is that on some systems
this can be 32 bit and on others 64 bit. I'm hoping to suggest to the
GNU gettext team that we could use signed values instead. For the time
being, I've wrapped my pluralizing numbers that are above 10000 into
the space 10000 - 19999... and then negative values can be discovered
by testing > 20000 in the .po pluralization formula. It's not an
elegant solution so if anyone has alternative suggestions I would love
to hear :)


On 13 September 2010 09:19, Bruno Haible <address@hidden> wrote:
> 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]