Browse Source

lenbuf on stack instead of heap

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac394@3421 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen 14 years ago
parent
commit
4c3ee31b90
1 changed files with 3 additions and 5 deletions
  1. 3 5
      src/lib/asiolink/tcpdns.cc

+ 3 - 5
src/lib/asiolink/tcpdns.cc

@@ -72,7 +72,7 @@ TCPServer::operator()(error_code ec, size_t length) {
     /// a switch statement, inline variable declarations are not
     /// permitted.  Certain variables used below can be declared here.
     boost::array<const_buffer,2> bufs;
-    OutputBuffer* lenbuf = NULL;
+    OutputBuffer lenbuf(TCP_MESSAGE_LENGTHSIZE);
 
     CORO_REENTER (this) {
         do {
@@ -162,9 +162,8 @@ TCPServer::operator()(error_code ec, size_t length) {
         (*answer_callback_)(*io_message_, message_, respbuf_);
 
         // Set up the response, beginning with two length bytes.
-        lenbuf = new OutputBuffer(TCP_MESSAGE_LENGTHSIZE);
-        lenbuf->writeUint16(respbuf_->getLength());
-        bufs[0] = buffer(lenbuf->getData(), lenbuf->getLength());
+        lenbuf.writeUint16(respbuf_->getLength());
+        bufs[0] = buffer(lenbuf.getData(), lenbuf.getLength());
         bufs[1] = buffer(respbuf_->getData(), respbuf_->getLength());
 
         // Begin an asynchronous send, and then yield.  When the
@@ -173,7 +172,6 @@ TCPServer::operator()(error_code ec, size_t length) {
         // will simply exit at that time).
         CORO_YIELD async_write(*socket_, bufs, *this);
     }
-    delete lenbuf;
 }
 
 /// Call the DNS lookup provider.  (Expected to be called by the