summaryrefslogtreecommitdiff
path: root/ACE/ace/SOCK_IO.cpp
diff options
context:
space:
mode:
authorAdam Mitz <mitza@ociweb.com>2015-11-06 17:07:11 -0600
committerAdam Mitz <mitza@ociweb.com>2015-11-06 17:07:11 -0600
commitac5e1702c9f9bee9f1f7bfce8c1a6f3847ea6b4b (patch)
tree0e70d1f51c39e688a05a6cdc2af58408222e4a0d /ACE/ace/SOCK_IO.cpp
parent5272b5b81f92c298cb998b5bb0b0dbca3e7f29fe (diff)
downloadATCD-ac5e1702c9f9bee9f1f7bfce8c1a6f3847ea6b4b.tar.gz
Merged branch ace-face-safety (FACE Safety Profile import from OCITAO).
Diffstat (limited to 'ACE/ace/SOCK_IO.cpp')
-rw-r--r--ACE/ace/SOCK_IO.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/ACE/ace/SOCK_IO.cpp b/ACE/ace/SOCK_IO.cpp
index 9048c8d3f56..e2b68a64545 100644
--- a/ACE/ace/SOCK_IO.cpp
+++ b/ACE/ace/SOCK_IO.cpp
@@ -4,6 +4,10 @@
#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/SOCK_IO.inl"
#endif /* __ACE_INLINE__ */
@@ -47,9 +51,16 @@ ACE_SOCK_IO::recvv (iovec *io_vec,
return -1;
else if (inlen > 0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (io_vec->iov_base,
+ static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * inlen)),
+ -1);
+#else
ACE_NEW_RETURN (io_vec->iov_base,
char[inlen],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
// It's ok to blindly cast this value since 'inlen' is an int and, thus,
// we can't get more than that back. Besides, if the recv() fails, we
// don't want that value cast to unsigned and returned.
@@ -73,7 +84,7 @@ ACE_SOCK_IO::recvv (iovec *io_vec,
// the ints (basically, an varargs version of writev). The count N is
// the *total* number of trailing arguments, *not* a couple of the
// number of tuple pairs!
-
+#ifndef ACE_LACKS_VA_FUNCTIONS
ssize_t
ACE_SOCK_IO::send (size_t n, ...) const
{
@@ -85,9 +96,16 @@ ACE_SOCK_IO::send (size_t n, ...) const
#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);
@@ -102,7 +120,11 @@ ACE_SOCK_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;
@@ -125,9 +147,16 @@ ACE_SOCK_IO::recv (size_t n, ...) const
#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);
@@ -142,10 +171,15 @@ ACE_SOCK_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
ACE_END_VERSIONED_NAMESPACE_DECL