Patch to libstc++: Remove strdup from locale_facets.tcc
Stephen M. Webb
stephen.webb@bregmasoft.com
Tue Sep 10 06:08:00 GMT 2002
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
More information about the Libstdc++
mailing list