Use a pool for messages when configured

This removes allocations of the Message object in message_bridge_server
by reusing buffers from a small pool.

Change-Id: Ibc7f3f73d7b5619bee50985a3ffb10b862684df8
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/network/sctp_lib.h b/aos/network/sctp_lib.h
index 6cd11a3..06152d8 100644
--- a/aos/network/sctp_lib.h
+++ b/aos/network/sctp_lib.h
@@ -115,7 +115,15 @@
     }
   }
 
+  // Returns a message returned from ReadMessage back to the pool.
+  void FreeMessage(aos::unique_c_ptr<Message> &&message);
+
+  // Allocates messages for the pool.  SetMaxSize must be set first.
+  void SetPoolSize(size_t pool_size);
+
  private:
+  aos::unique_c_ptr<Message> AcquireMessage();
+
   void CloseSocket();
   void DoSetMaxSize();
 
@@ -131,6 +139,9 @@
   size_t max_size_ = 1000;
 
   std::vector<aos::unique_c_ptr<Message>> partial_messages_;
+
+  bool use_pool_ = false;
+  std::vector<aos::unique_c_ptr<Message>> free_messages_;
 };
 
 // Returns the max network buffer available for reading for a socket.