mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-29 14:05:14 +08:00
d3a193e36c
2002-04-15 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/4164
Valgrind fixes.
* config/io/basic_file_stdio.cc (__basic_file::~__basic_file):
Call close.
(__basic_file::close): Call fflush. Correct return if fclose ok.
(__basic_file::is_open): Make const.
Change __c_file_type to __c_file.
* config/io/basic_file_stdio.h: Change __c_file_type to __c_file.
(__basic_file::is_open): Make const.
* config/io/c_io_stdio.h: Change __c_file_type to __c_file.
* include/std/std_fstream.h (filebuf::_M_allocate_file): Remove.
(filebuf::_M_unbuf): Add.
(filebuf::_M_file): Change to non-pointer.
(filebuf::_M_allocate_pback_buffer): Remove.
* include/bits/fstream.tcc (filebuf::_M_allocate_file): Remove.
(filebuf::_M_allocate_internal_buffer): Use _M_unbuf.
Change initialization list for _M_file change.
(filebuf::_M_allocate_pback_buffer): Remove.
Change _M_file usage to reflect non-pointer data member.
* config/locale/generic/c_locale.cc
(locale::facet::_S_create_c_locale): Add parameter.
* config/locale/generic/collate_members.cc: Change
_M_compare_helper to _M_compare.
Change _M_transform_helper to _M_transform.
* config/locale/generic/monetary_members.cc: Changeup data types.
Add dtors.
* config/locale/generic/numeric_members.cc: Add dtors.
* config/locale/generic/time_members.cc: Add dtors.
* config/locale/gnu/c_locale.cc: Add parameter.
* config/locale/gnu/collate_members.cc:Change
_M_compare_helper to _M_compare.
Change _M_transform_helper to _M_transform.
* config/locale/gnu/ctype_members.cc: Better error checking.
* config/os/gnu-linux/bits/ctype_noninline.h: Better error checking.
* config/locale/gnu/messages_members.cc: Tweak comment.
* config/locale/gnu/monetary_members.cc: Change data types.
Add dtors.
* config/locale/gnu/numeric_members.cc: Add dtors, better error
checking.
* config/locale/gnu/time_members.cc: Same.
* config/locale/ieee_1003.1-2001/c_locale.cc
(locale::facet::_S_create_c_locale): Add parameter.
* config/locale/ieee_1003.1-2001/c_locale.h: Correct typedef.
* config/locale/ieee_1003.1-2001/codecvt_specializations.h: Remove
bogus ctor.
* include/bits/locale_facets.h (moneypunct): Use string literals.
Don't define dtor.
(numpunct): Same.
(__timepunct): Same.
(locale::_Impl::_M_facets): Change from vector to array.
(locale::_Impl::_M_names): Change from array of strings to array
of string literals.
(locale::facet::_S_create_c_locale): Add parameter.
(locale::locale::_S_num_facets): Move to...
(locale::_Impl::_M_facets_size): Here.
* include/bits/locale_facets.tcc: Fixups for _M_facets, _M_name
changes.
* include/bits/localefwd.h: (locale:🆔:_M_id): Add member function.
(locale::_Impl::_Impl(facet**, size_t, bool)): Add.
(locale::_Impl::_Impl(string, size_t)): Change to
(locale::_Impl::_Impl(const char*, size_t)): This.
* include/bits/streambuf.tcc (streambuf::_S_pback_size): Define.
* include/std/std_streambuf.h (streambuf::_M_pback_size): Change to
(streambuf::_S_pback_size): This.
* src/globals.cc: Add pre-allocations for "C" facets.
* src/locale-inst.cc: Remove vector instantiations.
* src/locale.cc: Remove vector include. Fixups for _M_names,
_M_facets changes.
* src/localename.cc: Same.
* include/bits/stl_vector.h: Fix odd formatting.
* include/bits/basic_string.tcc: Tweak comment.
* libsupc++/new: Make sure parameters are uglified.
* libsupc++/typeinfo: Same.
* testsuite/22_locale/num_get_members_char.cc: Fixup.
* testsuite/22_locale/num_get_members_wchar_t.cc: Same.
* testsuite/27_io/filebuf_members.cc: Same.
From-SVN: r52345
95 lines
3.5 KiB
C++
95 lines
3.5 KiB
C++
// The -*- C++ -*- dynamic memory management header.
|
|
|
|
// Copyright (C) 1994, 1996, 1997, 1998, 2000, 2001, 2002
|
|
// Free Software Foundation
|
|
|
|
// This file is part of GNU CC.
|
|
//
|
|
// GNU CC is free software; you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation; either version 2, or (at your option)
|
|
// any later version.
|
|
//
|
|
// GNU CC is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with GNU CC; see the file COPYING. If not, write to
|
|
// the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
// Boston, MA 02111-1307, USA.
|
|
|
|
// As a special exception, you may use this file as part of a free software
|
|
// library without restriction. Specifically, if other files instantiate
|
|
// templates or use macros or inline functions from this file, or you compile
|
|
// this file and link it with other files to produce an executable, this
|
|
// file does not by itself cause the resulting executable to be covered by
|
|
// the GNU General Public License. This exception does not however
|
|
// invalidate any other reasons why the executable file might be covered by
|
|
// the GNU General Public License.
|
|
|
|
/** @file new
|
|
* The header @c new defines several functions to manage dynamic memory and
|
|
* handling memory allocation errors; see
|
|
* http://gcc.gnu.org/onlinedocs/libstdc++/18_support/howto.html#4 for more.
|
|
*/
|
|
|
|
#ifndef __NEW__
|
|
#define __NEW__
|
|
|
|
#include <cstddef>
|
|
#include <exception>
|
|
|
|
extern "C++" {
|
|
|
|
namespace std
|
|
{
|
|
/** @c bad_alloc (or classes derived from it) is used to report allocation
|
|
* errors from the throwing forms of @c new. */
|
|
class bad_alloc : public exception
|
|
{
|
|
public:
|
|
bad_alloc() throw() { }
|
|
// This declaration is not useless:
|
|
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
|
|
virtual ~bad_alloc() throw();
|
|
};
|
|
|
|
struct nothrow_t { };
|
|
extern const nothrow_t nothrow;
|
|
/** If you write your own error handler to be called by @c new, it must
|
|
* be of this type. */
|
|
typedef void (*new_handler)();
|
|
/// Takes a replacement handler as the argument, returns the previous handler.
|
|
new_handler set_new_handler(new_handler);
|
|
} // namespace std
|
|
|
|
//@{
|
|
/** These are replaceable signatures:
|
|
* - normal single new and delete (no arguments, throw @c bad_alloc on error)
|
|
* - normal array new and delete (same)
|
|
* - @c nothrow single new and delete (take a @c nothrow argument, return
|
|
* @c NULL on error)
|
|
* - @c nothrow array new and delete (same)
|
|
*
|
|
* Placement new and delete signatures (take a memory address argument,
|
|
* does nothing) may not be replaced by a user's program.
|
|
*/
|
|
void* operator new(std::size_t) throw (std::bad_alloc);
|
|
void* operator new[](std::size_t) throw (std::bad_alloc);
|
|
void operator delete(void*) throw();
|
|
void operator delete[](void*) throw();
|
|
void* operator new(std::size_t, const std::nothrow_t&) throw();
|
|
void* operator new[](std::size_t, const std::nothrow_t&) throw();
|
|
void operator delete(void*, const std::nothrow_t&) throw();
|
|
void operator delete[](void*, const std::nothrow_t&) throw();
|
|
|
|
// Default placement versions of operator new.
|
|
inline void* operator new(std::size_t, void* __p) throw() { return __p; }
|
|
inline void* operator new[](std::size_t, void* __p) throw() { return __p; }
|
|
//@}
|
|
} // extern "C++"
|
|
|
|
#endif
|