From aa35f75807932fc0bb8f1f8048579680bef74fcd Mon Sep 17 00:00:00 2001 From: bkoz Date: Fri, 30 Jan 2004 03:43:00 +0000 Subject: 2004-01-29 Stephen M. Webb * 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(). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@76922 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/config/locale/generic/c_locale.h | 10 ++++------ libstdc++-v3/config/locale/gnu/c_locale.h | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'libstdc++-v3/config') 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 -#include // get std::malloc #include // get std::strlen #include // 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(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 // get std::strlen -#include // get std::malloc #include // get std::snprintf or std::sprintf #include #include // 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(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; } -- cgit v1.2.1