OSDN Git Service

* include/bits/locale_facets.tcc (__convert_from_v):
authordannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Sep 2002 02:41:55 +0000 (02:41 +0000)
committerdannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Sep 2002 02:41:55 +0000 (02:41 +0000)
Replace strdup with ISO malloc and strcpy.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@56991 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc

index 787792a..e89c618 100644 (file)
@@ -1,3 +1,8 @@
+2002-09-10  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       * include/bits/locale_facets.tcc (__convert_from_v):
+       Replace strdup with ISO malloc and strcpy.
+
 2002-09-09  Benjamin Kosnik  <bkoz@redhat.com>
 
        * docs/html/configopts.html: Change grouping. Note ABI impacts.
index 63e52c0..ad7ba3f 100644 (file)
@@ -1976,14 +1976,17 @@ namespace std
                     _Tv __v, const __c_locale&, int __prec = -1)
     {
       int __ret;
-      char* __old = strdup(setlocale(LC_ALL, NULL));
+      char* __old = setlocale(LC_ALL, NULL);
+      char* __sav = static_cast<char*>(malloc(strlen(__old) + 1));
+      if (__sav)
+        strcpy(__sav, __old);
       setlocale(LC_ALL, "C");
       if (__prec >= 0)
         __ret = snprintf(__out, __size, __fmt, __prec, __v);
       else
         __ret = snprintf(__out, __size, __fmt, __v);
-      setlocale(LC_ALL, __old);
-      free(__old);
+      setlocale(LC_ALL, __sav);
+      free(__sav);
       return __ret;
     }
 #else
@@ -1993,14 +1996,17 @@ namespace std
                     const __c_locale&, int __prec = -1)
     {
       int __ret;
-      char* __old = strdup(setlocale(LC_ALL, NULL));
+      char* __old = setlocale(LC_ALL, NULL);
+      char* __sav = static_cast<char*>(malloc(strlen(__old) + 1));
+      if (__sav)
+        strcpy(__sav, __old);
       setlocale(LC_ALL, "C");
       if (__prec >= 0)
         __ret = sprintf(__out, __fmt, __prec, __v);
       else
         __ret = sprintf(__out, __fmt, __v);
-      setlocale(LC_ALL, __old);
-      free(__old);
+      setlocale(LC_ALL, __sav);
+      free(__sav);
       return __ret;
     }
 #endif