diff options
author | Like Ma <likemartinma@gmail.com> | 2019-02-26 10:11:56 +0800 |
---|---|---|
committer | Like Ma <likemartinma@gmail.com> | 2019-02-26 19:02:01 +0800 |
commit | 5c8c67c4e7d12d89da8e5f4fd925f2f01e201a76 (patch) | |
tree | fd8fe781e2d85bfaafbcd69ed9f0e85dcb788aba /ACE | |
parent | 5da2bfea6389df4b8adfaebc27eea7e7d55ff64d (diff) | |
download | ATCD-5c8c67c4e7d12d89da8e5f4fd925f2f01e201a76.tar.gz |
Fix wchar_t strnew and strdup.
Diffstat (limited to 'ACE')
-rw-r--r-- | ACE/ace/ACE.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/ACE/ace/ACE.cpp b/ACE/ace/ACE.cpp index 781ef3077eb..f10ab8225b2 100644 --- a/ACE/ace/ACE.cpp +++ b/ACE/ace/ACE.cpp @@ -3240,11 +3240,18 @@ ACE::strndup (const wchar_t *str, size_t n) len++) continue; + size_t const size = (len + 1) * sizeof (wchar_t); wchar_t *s; +#if defined (ACE_HAS_ALLOC_HOOKS) + ACE_ALLOCATOR_RETURN (s, + static_cast<wchar_t*> ( + ACE_Allocator::instance ()->malloc (size)), + 0); +#else ACE_ALLOCATOR_RETURN (s, - static_cast<wchar_t *> ( - ACE_OS::malloc ((len + 1) * sizeof (wchar_t))), + static_cast<wchar_t*> (ACE_OS::malloc (size)), 0); +#endif /* ACE_HAS_ALLOC_HOOKS */ return ACE_OS::strsncpy (s, str, len + 1); } #endif /* ACE_HAS_WCHAR */ @@ -3346,10 +3353,19 @@ ACE::strnew (const wchar_t *s) { if (s == 0) return 0; + + size_t const n = ACE_OS::strlen (s) + 1; wchar_t *t = 0; - ACE_NEW_RETURN (t, - wchar_t[ACE_OS::strlen (s) + 1], - 0); +#if defined (ACE_HAS_ALLOC_HOOKS) + ACE_ALLOCATOR_RETURN (t, + static_cast<wchar_t*> ( + ACE_Allocator::instance ()->malloc ( + sizeof (wchar_t) * (n))), + 0); +#else + ACE_NEW_RETURN (t, wchar_t[n], 0); +#endif /* ACE_HAS_ALLOC_HOOKS */ + return ACE_OS::strcpy (t, s); } #endif /* ACE_HAS_WCHAR */ |