Patch to libstc++: Remove strdup from locale_facets.tcc

Loren James Rittle rittle@latour.rsch.comm.mot.com
Tue Sep 10 20:31:00 GMT 2002


> This is not a criticism of the patch but more of a philosophical 
> question.

> Would it not be better to replace with the strdup call with a 
> get_temporary_buffer and copy (or maybe strcpy)?  While at the moment 
> get_temporary_buffer is just a malloc call, some day it might be fixed 
> to use a pooled allocator or some more thread-friendly scheme, or 
> perhaps use new instead of malloc?

I think yes on all counts.

> Is there in fact any guiding policy on non-Allocator memory allocation 
> within libstdc++?

None documented AFAIK.  If the allocator abstraction is good enough
for traditional STL and string<>, then why should it not be used
everywhere within libstdc++-v3?

> Should there be, in an effort to be thread-friendly 

The malloc/free pairs should itself be thread-friendly on any system
that claims to have a thread-friendly libc.

> and consistent in the presence of exceptions?

Yes, the naked malloc/free pair clearly fails on this point unless one
is quite careful.

Regards,
Loren



More information about the Libstdc++ mailing list