This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Patch to libstc++: Remove strdup from locale_facets.tcc
- From: Stephen M. Webb <stephen dot webb at bregmasoft dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Tue, 10 Sep 2002 09:19:49 -0400
- Subject: Re: Patch to libstc++: Remove strdup from locale_facets.tcc
- Organization: Bregmasoft
- References: <20020909230558.46315.qmail@web14501.mail.yahoo.com>
- Reply-to: stephen dot webb at bregmasoft dot com
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