This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
auto_ptr in locale
- To: libstdc++ at sourceware dot cygnus dot com
- Subject: auto_ptr in locale
- From: Benjamin Kosnik <bkoz at cygnus dot com>
- Date: Fri, 19 Nov 1999 16:33:10 -0800 (PST)
from nathan, who seems to be having problems with this list . . .
---------- Forwarded message ----------
Date: Fri, 19 Nov 1999 16:15:51 -0800
From: Nathan Myers <ncm@zembu.com>
Reply-To: ncm@cantrip.org
To: bkoz@cygnus.com
Cc: kediger@licor.com, jsm@cygnus.com
Subject: auto_ptr in locale
Benjamin,
I'm sending this to you and Kevin rather than to the list because
Crash has made lists MUA-hostile, and I am tired of fighting with
him and them. You can forward this to the list yourself, if you
think it would be useful.
> The constructors for locale::__Impl
> don't look correct to me. There are some try...catch handlers that
> probably were intended to prevent memory leaks, but they don't do
> that and I think a core dump is inevitable if an exception does
> occur; the code deletes _M_facets and _M_category_names when the
> compiler should have already taken care of that.
>
> Here's a patch that uses auto_ptr to make the constructors exception
> safe.
I agree that the code Kevin is replacing is badly wrong, and that his
code seems to fix the parts visible in the patch. However, I don't like
his choice of names (pvf and pcn) -- they look like Hungarian notation
to me, and are singularly uninformative. Furthermore, since this code
is in a ".cc" file, they don't need to be uglified. Furtherfurthermore,
the typedefs __vec_facet and __vec_string disobey the library naming
convention that non-standard type names are capitalized.
What's wrong with just:
auto_ptr<Vec_facet> facets(new Vec_facet(__numfacets,(facet*)0));
auto_ptr<Vec_string> names(new Vec_string(_S_num_categories,string("*")
?
Kevin, can you fix these things and send another patch?
I don't know where the buggy code came from. My code had those
vectors as ordinary members of locale::_Impl. Somebody changed them
to pointers, and incidentally broke the constructor. Furthermore, my
code didn't have uglified local variable names.
Benjamin, do you know anything about why those members were removed
from the class body and replaced with pointers? Do you know who
improperly uglified the names? Has improper uglification spread
elsewhere in the library?
Nathan
ncm@cantrip.org