From 809a347333f01217b9dfd32d61f44b615aa1bad6 Mon Sep 17 00:00:00 2001 From: crs Date: Tue, 2 Sep 2003 22:06:07 +0000 Subject: [PATCH] Removed heap allocation when polling sockets. --- lib/arch/CArchNetworkBSD.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/arch/CArchNetworkBSD.cpp b/lib/arch/CArchNetworkBSD.cpp index 9b6eec6d..1db5df82 100644 --- a/lib/arch/CArchNetworkBSD.cpp +++ b/lib/arch/CArchNetworkBSD.cpp @@ -274,7 +274,8 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout) } // allocate space for translated query - struct pollfd* pfd = new struct pollfd[num]; + struct pollfd* pfd = reinterpret_cast( + alloca(num * sizeof(struct pollfd))); // translate query for (int i = 0; i < num; ++i) { @@ -298,7 +299,6 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout) ARCH->testCancelThread(); continue; } - delete[] pfd; throwError(errno); } } while (false); @@ -320,9 +320,6 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout) } } - // done with translated query - delete[] pfd; - return n; }