aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2002-04-09 21:19:55 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2002-04-09 21:19:55 +0000
commit0dba73e0ab4dba1f4f4850f326950bc91581329e (patch)
tree0b2f11adc74771559ca399c135af50f2535e53cd /libstdc++-v3/src
parentb47374fa9bcf1d1349d9292610b8878692dd0ee0 (diff)
downloadgcc-0dba73e0ab4dba1f4f4850f326950bc91581329e.tar.gz
gcc-0dba73e0ab4dba1f4f4850f326950bc91581329e.tar.bz2
gcc-0dba73e0ab4dba1f4f4850f326950bc91581329e.zip
localefwd.h (locale::_Impl::_M_facets): Change from pointer to vector.
2002-04-09 Benjamin Kosnik <bkoz@redhat.com> libstdc++/1072 * include/bits/localefwd.h (locale::_Impl::_M_facets): Change from pointer to vector. Remove forward declaration of vector. Include vector. * include/bits/locale_facets.tcc: Remove vector include. (use_locale): Adjust. (has_locale): Adjust. * src/locale.cc: Adjust. * src/localename.cc: Same. From-SVN: r52095
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/locale.cc4
-rw-r--r--libstdc++-v3/src/localename.cc59
2 files changed, 24 insertions, 39 deletions
diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc
index 02177ed73c5..0b1056c045d 100644
--- a/libstdc++-v3/src/locale.cc
+++ b/libstdc++-v3/src/locale.cc
@@ -500,7 +500,7 @@ namespace std
{
size_t __i = ctype<char>::id._M_index;
const locale::_Impl* __tmp = __loc._M_impl;
- return static_cast<const ctype<char>&>(* (*(__tmp->_M_facets))[__i]);
+ return static_cast<const ctype<char>&>(*(__tmp->_M_facets[__i]));
}
#ifdef _GLIBCPP_USE_WCHAR_T
@@ -510,7 +510,7 @@ namespace std
{
size_t __i = ctype<wchar_t>::id._M_index;
const locale::_Impl* __tmp = __loc._M_impl;
- return static_cast<const ctype<wchar_t>&>(* (*(__tmp->_M_facets))[__i]);
+ return static_cast<const ctype<wchar_t>&>(*(__tmp->_M_facets[__i]));
}
#endif
diff --git a/libstdc++-v3/src/localename.cc b/libstdc++-v3/src/localename.cc
index ad816486705..53c9e8a0347 100644
--- a/libstdc++-v3/src/localename.cc
+++ b/libstdc++-v3/src/localename.cc
@@ -36,31 +36,25 @@ namespace std
locale::_Impl::
~_Impl() throw()
{
- __vec_facet::iterator it = _M_facets->begin();
- for (; it != _M_facets->end(); ++it)
- if (*it)
- (*it)->_M_remove_reference();
- delete _M_facets;
+ __vec_facet::iterator __it = _M_facets.begin();
+ __vec_facet::iterator __end = _M_facets.end();
+ for (; __it != __end; ++__it)
+ if (*__it)
+ (*__it)->_M_remove_reference();
}
// Clone existing _Impl object.
locale::_Impl::
_Impl(const _Impl& __imp, size_t __refs)
- : _M_references(__refs), _M_facets(0) // XXX
+ : _M_references(__refs) // XXX
{
- try
- { _M_facets = new __vec_facet(*(__imp._M_facets)); }
- catch(...)
- {
- delete _M_facets;
- __throw_exception_again;
- }
+ _M_facets = __imp._M_facets;
+ for (size_t __i = 0; __i < _S_num_categories; ++__i)
+ _M_names[__i] = __imp._M_names[__i];
- for (size_t i = 0; i < _S_num_categories; ++i)
- _M_names[i] = __imp._M_names[i];
-
- __vec_facet::iterator __it = _M_facets->begin();
- for (; __it != _M_facets->end(); ++__it)
+ __vec_facet::iterator __it = _M_facets.begin();
+ __vec_facet::iterator __end = _M_facets.end();
+ for (; __it != __end; ++__it)
if (*__it)
(*__it)->_M_add_reference();
}
@@ -68,7 +62,7 @@ namespace std
// Construct named _Impl, including the standard "C" locale.
locale::_Impl::
_Impl(string __str, size_t __refs)
- : _M_references(__refs), _M_facets(0)
+ : _M_references(__refs)
{
// Initialize the underlying locale model, which also checks to
// see if the given name is valid.
@@ -81,14 +75,7 @@ namespace std
if (__str != "C" && __str != "POSIX")
__cloc_c = __cloc;
- // Allocate facet container.
- try
- { _M_facets = new __vec_facet(_S_num_facets, NULL); }
- catch(...)
- {
- delete _M_facets;
- __throw_exception_again;
- }
+ _M_facets = __vec_facet(_S_num_facets, NULL);
// Name all the categories.
for (size_t i = 0; i < _S_num_categories; ++i)
@@ -162,12 +149,11 @@ namespace std
_M_replace_facet(const _Impl* __imp, const locale::id* __idp)
{
size_t __index = __idp->_M_index;
- if (__index == 0
- || __imp->_M_facets->size() <= __index
- || (*(__imp->_M_facets))[__index] == 0)
+ if (__index == 0 || __imp->_M_facets.size() <= __index
+ || __imp->_M_facets[__index] == 0)
__throw_runtime_error("no locale facet");
- _M_install_facet(__idp, (*(__imp->_M_facets))[__index]);
+ _M_install_facet(__idp, __imp->_M_facets[__index]);
}
void
@@ -180,14 +166,13 @@ namespace std
if (!__index)
__index = 1 + __exchange_and_add(&locale::id::_S_highwater, 1);
- if (__index >= _M_facets->size())
- _M_facets->resize(__index + 1, 0); // might throw
+ if (__index >= _M_facets.size())
+ _M_facets.resize(__index + 1, 0); // might throw
- facet*& __fpr = (*_M_facets)[__index];
+ facet*& __fpr = _M_facets[__index];
if (__fpr)
{
- // Replacing an existing facet.
- // Order matters, here:
+ // Replacing an existing facet. Order matters.
__fp->_M_add_reference();
__fpr->_M_remove_reference();
__fpr = __fp;
@@ -197,7 +182,7 @@ namespace std
// Installing a newly created facet into an empty
// _M_facets container, say a newly-constructed,
// swanky-fresh _Impl.
- (*_M_facets)[__index] = __fp;
+ _M_facets[__index] = __fp;
}
}
}