|
1 | 1 | #include "crypto/crypto_hash.h"
|
2 | 2 | #include "async_wrap-inl.h"
|
3 | 3 | #include "base_object-inl.h"
|
| 4 | +#include "cppgc/allocation.h" |
| 5 | +#include "cppgc_helpers-inl.h" |
4 | 6 | #include "env-inl.h"
|
5 | 7 | #include "memory_tracker-inl.h"
|
6 | 8 | #include "string_bytes.h"
|
@@ -31,14 +33,23 @@ using v8::Object;
|
31 | 33 | using v8::Uint32;
|
32 | 34 | using v8::Value;
|
33 | 35 |
|
| 36 | +#ifdef ASSIGN_OR_RETURN_UNWRAP |
| 37 | +#undef ASSIGN_OR_RETURN_UNWRAP |
| 38 | +#endif |
| 39 | + |
| 40 | +#define ASSIGN_OR_RETURN_UNWRAP ASSIGN_OR_RETURN_UNWRAP_CPPGC |
34 | 41 | namespace crypto {
|
35 |
| -Hash::Hash(Environment* env, Local<Object> wrap) : BaseObject(env, wrap) { |
36 |
| - MakeWeak(); |
| 42 | +Hash::Hash(Environment* env, Local<Object> wrap) { |
| 43 | + CppgcMixin::Wrap(this, env, wrap); |
| 44 | +} |
| 45 | + |
| 46 | +void Hash::Trace(cppgc::Visitor* visitor) const { |
| 47 | + CppgcMixin::Trace(visitor); |
37 | 48 | }
|
38 | 49 |
|
39 | 50 | void Hash::MemoryInfo(MemoryTracker* tracker) const {
|
40 |
| - tracker->TrackFieldWithSize("mdctx", mdctx_ ? kSizeOf_EVP_MD_CTX : 0); |
41 |
| - tracker->TrackFieldWithSize("md", digest_ ? md_len_ : 0); |
| 51 | + tracker->TrackFieldWithSize("mdctx", mdctx_ ? kSizeOf_EVP_MD_CTX : 0, "EVP_MD_CTX"); |
| 52 | + tracker->TrackFieldWithSize("md", digest_ ? md_len_ : 0, "ByteSource"); |
42 | 53 | }
|
43 | 54 |
|
44 | 55 | #if OPENSSL_VERSION_MAJOR >= 3
|
@@ -322,7 +333,8 @@ void Hash::New(const FunctionCallbackInfo<Value>& args) {
|
322 | 333 | xof_md_len = Just<unsigned int>(args[1].As<Uint32>()->Value());
|
323 | 334 | }
|
324 | 335 |
|
325 |
| - Hash* hash = new Hash(env, args.This()); |
| 336 | + Hash* hash = cppgc::MakeGarbageCollected<Hash>( |
| 337 | + env->isolate()->GetCppHeap()->GetAllocationHandle(), env, args.This()); |
326 | 338 | if (md == nullptr || !hash->HashInit(md, xof_md_len)) {
|
327 | 339 | return ThrowCryptoError(env, ERR_get_error(),
|
328 | 340 | "Digest method not supported");
|
|
0 commit comments