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

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

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


##########
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:
   I thought I may be able to calculate the minimal size but realized that  it requires including header files for SHA256 and MD5.



-- 
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