Still improving! (Was: Re: [PATCH] Avoid strtok for thread safety)

Benjamin Kosnik bkoz@redhat.com
Wed Nov 27 14:20:00 GMT 2002


>Some time ago, in private mail he alluded to some troubles with memory 
>leaks and static allocation of strings, which led him to resort to C 
>strings (std::strings were in fact used, in the first implementation!). 
>If you browse a bit the repository you will learn, I think, that this 
>happened exactly when Benjamin started to systematically fight memory 
>leaks with Valgrind.

Before std::strings can be used, dealing with a persistent string or
strings for "C" locales needs to be done. I couldn't figure out how to
do this, so I switched. I posted about this on the libstdc++ list, and
there were no other suggestions.

For what's being done here, std::strings are probably overkill, IMHO.
Reasonable people may differ, and do.

If you're worried about exception-safety, you can always add try/catch
blocks around these allocations.

-benjamin



More information about the Libstdc++ mailing list