This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On September 9, 2002 07:05 pm, Danny Smith wrote:
> This code:
>
> #include <iostream>
> void foo() {
>   int bar = 1;
>   std::cout << bar << std::endl;
> }
>
> fails when compiled with -O3 -ansi because non-ANSI strdup
> in locale_facets.tcc is exposed by inlining and strdup is guarded by
> __STRICT_ANSI__ in C runtime string.h

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?


Is there in fact any guiding policy on non-Allocator memory allocation 
within libstdc++?  Should there be, in an effort to be thread-friendly 
and consistent in the presence of exceptions?

-- 
Stephen M. Webb


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]