You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "SolidWallOfCode (via GitHub)" <gi...@apache.org> on 2023/03/07 17:38:03 UTC

[GitHub] [trafficserver] SolidWallOfCode commented on a diff in pull request #9474: Avoid memory allocation in CryptoHash

SolidWallOfCode commented on code in PR #9474:
URL: https://github.com/apache/trafficserver/pull/9474#discussion_r1128285477


##########
include/tscore/CryptoHash.h:
##########
@@ -168,26 +168,23 @@ class CryptoContext : public CryptoContextBase
   }; ///< What type of hash we really are.
   static HashType Setting;
 
-  ~CryptoContext()
-  {
-    delete _base;
-    _base = nullptr;
-  }
+  ~CryptoContext() { reinterpret_cast<CryptoContextBase *>(_base)->~CryptoContextBase(); }
 
 private:
-  CryptoContextBase *_base = nullptr;
+  static size_t constexpr OBJ_SIZE = 256;

Review Comment:
   It would probably be good to have some test or debug logic that does calculate the minimum size.



-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org