summaryrefslogtreecommitdiff
path: root/ace/OS_NS_time.inl
diff options
context:
space:
mode:
Diffstat (limited to 'ace/OS_NS_time.inl')
-rw-r--r--ace/OS_NS_time.inl28
1 files changed, 18 insertions, 10 deletions
diff --git a/ace/OS_NS_time.inl b/ace/OS_NS_time.inl
index 99ca079478c..fbce238b080 100644
--- a/ace/OS_NS_time.inl
+++ b/ace/OS_NS_time.inl
@@ -7,6 +7,7 @@
#include "ace/Time_Value.h"
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_sys_time.h"
+//#include "ace/TSS_T.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -115,24 +116,31 @@ ACE_OS::ctime (const time_t *t)
#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
ACE_OSCALL_RETURN (::_wctime (t), wchar_t *, 0);
#else
-# if defined (ACE_USES_WCHAR) /* Not Win32, else it would do the above */
+# if defined (ACE_USES_WCHAR) // Wide and not Win32
char *narrow_time;
ACE_OSCALL (::ctime (t), char *, 0, narrow_time);
if (narrow_time == 0)
return 0;
- // ACE_Ascii_To_Wide::convert allocates (via new []) a wchar_t[]. If
+ // ACE_TEXT_TO_MALLOC_WCHAR_OUT allocates (via malloc) a wchar_t[]. If
// we've done this before, free the previous one. Yes, this leaves a
// small memory leak (26 characters) but there's no way around this
// that I know of. (Steve Huston, 12-Feb-2003).
- static wchar_t *wide_time = 0;
- if (wide_time != 0)
- delete [] wide_time;
- wide_time = ACE_Ascii_To_Wide::convert (narrow_time);
+// Including ACE_TSS_T.h causes error!
+/*
+ wchar_t* init = 0;
+ static ACE_TSS< wchar_t* > wide_time (&init);
+ ACE::String_Conversion::Allocator_malloc<wchar_t>().free(*wide_time);
+ *wide_time.ts_object() = ACE_TEXT_TO_MALLOC_WCHAR_OUT (narrow_time);
+ return *wide_time;
+*/
+ static wchar_t* wide_time = 0;
+ ACE::String_Conversion::Allocator_malloc<wchar_t>().free(wide_time);
+ wide_time = ACE_TEXT_TO_MALLOC_WCHAR_OUT (narrow_time);
return wide_time;
# else
ACE_OSCALL_RETURN (::ctime (t), char *, 0);
-# endif /* ACE_USES_WCHAR */
-# endif /* ACE_HAS_BROKEN_CTIME */
+# endif // ACE_USES_WCHAR
+# endif // ACE_HAS_BROKEN_CTIME
}
#if !defined (ACE_HAS_WINCE) /* CE version in OS.cpp */
@@ -178,8 +186,7 @@ ACE_OS::ctime_r (const time_t *t, ACE_TCHAR *buf, int buflen)
return 0;
# if defined (ACE_USES_WCHAR)
- ACE_Ascii_To_Wide wide_buf (bufp);
- ACE_OS_String::strcpy (buf, wide_buf.wchar_rep ());
+ ACE_OS::string_copy (buf, bufp, buflen);
return buf;
# else
return bufp;
@@ -558,4 +565,5 @@ ACE_OS::tzset (void)
# endif /* ACE_HAS_WINCE && !VXWORKS && !ACE_PSOS && !__rtems__ && !ACE_HAS_DINKUM_STL */
}
+
ACE_END_VERSIONED_NAMESPACE_DECL