diff options
author | Adam Mitz <mitza@ociweb.com> | 2015-11-06 17:07:11 -0600 |
---|---|---|
committer | Adam Mitz <mitza@ociweb.com> | 2015-11-06 17:07:11 -0600 |
commit | ac5e1702c9f9bee9f1f7bfce8c1a6f3847ea6b4b (patch) | |
tree | 0e70d1f51c39e688a05a6cdc2af58408222e4a0d /ACE/ace/FILE_IO.cpp | |
parent | 5272b5b81f92c298cb998b5bb0b0dbca3e7f29fe (diff) | |
download | ATCD-ac5e1702c9f9bee9f1f7bfce8c1a6f3847ea6b4b.tar.gz |
Merged branch ace-face-safety (FACE Safety Profile import from OCITAO).
Diffstat (limited to 'ACE/ace/FILE_IO.cpp')
-rw-r--r-- | ACE/ace/FILE_IO.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/ACE/ace/FILE_IO.cpp b/ACE/ace/FILE_IO.cpp index f79b6827a6f..1a999c83e83 100644 --- a/ACE/ace/FILE_IO.cpp +++ b/ACE/ace/FILE_IO.cpp @@ -4,6 +4,9 @@ #include "ace/OS_NS_sys_stat.h" #include "ace/OS_Memory.h" #include "ace/Truncate.h" +#if defined (ACE_HAS_ALLOC_HOOKS) +# include "ace/Malloc_Base.h" +#endif /* ACE_HAS_ALLOC_HOOKS */ #if !defined (__ACE_INLINE__) #include "ace/FILE_IO.inl" @@ -43,15 +46,26 @@ ssize_t ACE_FILE_IO::send (size_t n, ...) const { ACE_TRACE ("ACE_FILE_IO::send"); +#ifdef ACE_LACKS_VA_FUNCTIONS + ACE_UNUSED_ARG (n); + ACE_NOTSUP_RETURN (-1); +#else va_list argp; int total_tuples = ACE_Utils::truncate_cast<int> (n / 2); iovec *iovp = 0; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else +# ifdef ACE_HAS_ALLOC_HOOKS + ACE_ALLOCATOR_RETURN (iovp, (iovec *) + ACE_Allocator::instance ()->malloc (total_tuples * + sizeof (iovec)), + -1); +# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); +# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -66,10 +80,15 @@ ACE_FILE_IO::send (size_t n, ...) const iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) +# ifdef ACE_HAS_ALLOC_HOOKS + ACE_Allocator::instance ()->free (iovp); +# else delete [] iovp; +# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; +#endif // ACE_LACKS_VA_FUNCTIONS } // This is basically an interface to ACE_OS::readv, that doesn't use @@ -82,15 +101,26 @@ ssize_t ACE_FILE_IO::recv (size_t n, ...) const { ACE_TRACE ("ACE_FILE_IO::recv"); +#ifdef ACE_LACKS_VA_FUNCTIONS + ACE_UNUSED_ARG (n); + ACE_NOTSUP_RETURN (-1); +#else va_list argp; int total_tuples = ACE_Utils::truncate_cast<int> (n / 2); iovec *iovp = 0; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); #else +# ifdef ACE_HAS_ALLOC_HOOKS + ACE_ALLOCATOR_RETURN (iovp, (iovec *) + ACE_Allocator::instance ()->malloc (total_tuples * + sizeof (iovec)), + -1); +# else ACE_NEW_RETURN (iovp, iovec[total_tuples], -1); +# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_start (argp, n); @@ -105,10 +135,15 @@ ACE_FILE_IO::recv (size_t n, ...) const iovp, total_tuples); #if !defined (ACE_HAS_ALLOCA) +# ifdef ACE_HAS_ALLOC_HOOKS + ACE_Allocator::instance ()->free (iovp); +# else delete [] iovp; +# endif /* ACE_HAS_ALLOC_HOOKS */ #endif /* !defined (ACE_HAS_ALLOCA) */ va_end (argp); return result; +#endif // ACE_LACKS_VA_FUNCTIONS } // Allows a client to read from a file without having to provide a @@ -128,9 +163,15 @@ ACE_FILE_IO::recvv (iovec *io_vec) { // Restrict to max size we can record in iov_len. size_t len = ACE_Utils::truncate_cast<u_long> (length); +#if defined (ACE_HAS_ALLOC_HOOKS) + ACE_ALLOCATOR_RETURN (io_vec->iov_base, + static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * len)), + -1); +#else ACE_NEW_RETURN (io_vec->iov_base, char[len], -1); +#endif /* ACE_HAS_ALLOC_HOOKS */ io_vec->iov_len = static_cast<u_long> (this->recv_n (io_vec->iov_base, len)); return io_vec->iov_len; |