moonchen commented on code in PR #13293:
URL: https://github.com/apache/trafficserver/pull/13293#discussion_r3431819398


##########
include/iocore/net/ProxyProtocol.h:
##########
@@ -82,6 +82,25 @@ class ProxyProtocol
     other.tlv.clear();
   }
   ~ProxyProtocol() = default;
+
+  /** Release owned heap and reset to the default-constructed state.
+   *
+   * Swap rather than clear() the containers: clear() retains capacity, which 
would be abandoned
+   * (leaked) when the slot is reused, since the NetVConnection allocators are 
Destruct_on_free=false
+   * and so never run ~ProxyProtocol.
+   */
+  void
+  reset()
+  {
+    std::string{}.swap(additional_data);
+    std::unordered_map<uint8_t, std::string_view>{}.swap(tlv);

Review Comment:
   if the types change here, so could the meaning of swap().  I'd rather make 
it explicit so the programmer can make the call.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to