summaryrefslogtreecommitdiff
path: root/libstdc++-v3/config
diff options
context:
space:
mode:
authorStephen M. Webb <stephen.webb@bregmasoft.com>2004-01-30 03:43:00 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2004-01-30 03:43:00 +0000
commit917a9fd4d5ce9ee5c906abb10812a316b77fc31c (patch)
treefcf9db0ae11adc880d72ac1fdbb94ef6a98414ca /libstdc++-v3/config
parentae8f0c17739a44cfeb118280fc59626108b1eb5f (diff)
downloadgcc-917a9fd4d5ce9ee5c906abb10812a316b77fc31c.tar.gz
c_locale.h: Change ::malloc() to new char[].
2004-01-29 Stephen M. Webb <stephen.webb@bregmasoft.com> * config/local/generic/c_locale.h: Change ::malloc() to new char[]. * config/local/gnu/c_locale.h: Change ::malloc() to new char[]. * include/bits/stl_tempbuf.h: Convert _Temporary_buffer to use std::get_temporary_buffer() instead of duplicating its code. Update to C++STYLE conventions. * include/std/std_memory.h (get_temporary_buffer): Use ::operator new() instead of std::malloc(). (return_temporary_buffer): Use ::operator delete() instead of std::free(). From-SVN: r76922
Diffstat (limited to 'libstdc++-v3/config')
-rw-r--r--libstdc++-v3/config/locale/generic/c_locale.h10
-rw-r--r--libstdc++-v3/config/locale/gnu/c_locale.h10
2 files changed, 8 insertions, 12 deletions
diff --git a/libstdc++-v3/config/locale/generic/c_locale.h b/libstdc++-v3/config/locale/generic/c_locale.h
index c20b98ba24d..9fadcc4d99c 100644
--- a/libstdc++-v3/config/locale/generic/c_locale.h
+++ b/libstdc++-v3/config/locale/generic/c_locale.h
@@ -1,6 +1,6 @@
// Wrapper for underlying C-language localization -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -39,7 +39,6 @@
#pragma GCC system_header
#include <clocale>
-#include <cstdlib> // get std::malloc
#include <cstring> // get std::strlen
#include <cstdio> // get std::snprintf or std::sprintf
@@ -61,9 +60,8 @@ namespace std
_Tv __v, const __c_locale&, int __prec = -1)
{
char* __old = std::setlocale(LC_ALL, NULL);
- char* __sav = static_cast<char*>(std::malloc(std::strlen(__old) + 1));
- if (__sav)
- std::strcpy(__sav, __old);
+ char* __sav = new char[std::strlen(__old) + 1];
+ std::strcpy(__sav, __old);
std::setlocale(LC_ALL, "C");
int __ret;
@@ -79,7 +77,7 @@ namespace std
__ret = std::sprintf(__out, __fmt, __v);
#endif
std::setlocale(LC_ALL, __sav);
- std::free(__sav);
+ delete [] __sav;
return __ret;
}
}
diff --git a/libstdc++-v3/config/locale/gnu/c_locale.h b/libstdc++-v3/config/locale/gnu/c_locale.h
index 069074eb9fe..fe899cfc2a5 100644
--- a/libstdc++-v3/config/locale/gnu/c_locale.h
+++ b/libstdc++-v3/config/locale/gnu/c_locale.h
@@ -1,6 +1,6 @@
// Wrapper for underlying C-language localization -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -39,7 +39,6 @@
#pragma GCC system_header
#include <cstring> // get std::strlen
-#include <cstdlib> // get std::malloc
#include <cstdio> // get std::snprintf or std::sprintf
#include <clocale>
#include <langinfo.h> // For codecvt
@@ -76,9 +75,8 @@ namespace std
_Tv __v, const __c_locale&, int __prec = -1)
{
char* __old = std::setlocale(LC_ALL, NULL);
- char* __sav = static_cast<char*>(std::malloc(std::strlen(__old) + 1));
- if (__sav)
- std::strcpy(__sav, __old);
+ char* __sav = new char[std::strlen(__old) + 1];
+ std::strcpy(__sav, __old);
std::setlocale(LC_ALL, "C");
#endif
@@ -99,7 +97,7 @@ namespace std
__gnu_cxx::__uselocale(__old);
#else
std::setlocale(LC_ALL, __sav);
- std::free(__sav);
+ delete [] __sav;
#endif
return __ret;
}