| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 113dd2b commit a05c49c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5565,9 +5565,9 @@ void PBKDF2Request::After() { | |||
| 5565 | 5565 | ||
| 5566 | 5566 | void PBKDF2Request::After(uv_work_t* work_req, int status) { | |
| 5567 | 5567 | CHECK_EQ(status, 0); | |
| 5568 | - PBKDF2Request* req = ContainerOf(&PBKDF2Request::work_req_, work_req); | ||
| 5568 | + std::unique_ptr<PBKDF2Request> req( | ||
| 5569 | + ContainerOf(&PBKDF2Request::work_req_, work_req)); | ||
| 5569 | 5570 | req->After(); | |
| 5570 | - delete req; | ||
| 5571 | 5571 | } | |
| 5572 | 5572 | ||
| 5573 | 5573 | ||
@@ -5582,7 +5582,6 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) { | |||
| 5582 | 5582 | double raw_keylen = -1; | |
| 5583 | 5583 | int keylen = -1; | |
| 5584 | 5584 | int iter = -1; | |
| 5585 | - PBKDF2Request* req = nullptr; | ||
| 5586 | 5585 | Local<Object> obj; | |
| 5587 | 5586 | ||
| 5588 | 5587 | passlen = Buffer::Length(args[0]); | |
@@ -5618,15 +5617,9 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) { | |||
| 5618 | 5617 | ||
| 5619 | 5618 | obj = env->pbkdf2_constructor_template()-> | |
| 5620 | 5619 | NewInstance(env->context()).ToLocalChecked(); | |
| 5621 | - req = new PBKDF2Request(env, | ||
| 5622 | - obj, | ||
| 5623 | - digest, | ||
| 5624 | - passlen, | ||
| 5625 | - pass, | ||
| 5626 | - saltlen, | ||
| 5627 | - salt, | ||
| 5628 | - iter, | ||
| 5629 | - keylen); | ||
| 5620 | + std::unique_ptr<PBKDF2Request> req( | ||
| 5621 | + new PBKDF2Request(env, obj, digest, passlen, pass, saltlen, salt, iter, | ||
| 5622 | + keylen)); | ||
| 5630 | 5623 | ||
| 5631 | 5624 | if (args[5]->IsFunction()) { | |
| 5632 | 5625 | obj->Set(env->ondone_string(), args[5]); | |
@@ -5639,15 +5632,14 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) { | |||
| 5639 | 5632 | } | |
| 5640 | 5633 | ||
| 5641 | 5634 | uv_queue_work(env->event_loop(), | |
| 5642 | - req->work_req(), | ||
| 5635 | + req.release()->work_req(), | ||
| 5643 | 5636 | PBKDF2Request::Work, | |
| 5644 | 5637 | PBKDF2Request::After); | |
| 5645 | 5638 | } else { | |
| 5646 | 5639 | env->PrintSyncTrace(); | |
| 5647 | 5640 | req->Work(); | |
| 5648 | 5641 | Local<Value> argv[2]; | |
| 5649 | 5642 | req->After(&argv); | |
| 5650 | - delete req; | ||
| 5651 | 5643 | ||
| 5652 | 5644 | if (argv[0]->IsObject()) | |
| 5653 | 5645 | env->isolate()->ThrowException(argv[0]); | |
@@ -5785,25 +5777,23 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> (*argv)[2]) { | |||
| 5785 | 5777 | ||
| 5786 | 5778 | void RandomBytesAfter(uv_work_t* work_req, int status) { | |
| 5787 | 5779 | CHECK_EQ(status, 0); | |
| 5788 | - RandomBytesRequest* req = | ||
| 5789 | - ContainerOf(&RandomBytesRequest::work_req_, work_req); | ||
| 5780 | + std::unique_ptr<RandomBytesRequest> req( | ||
| 5781 | + ContainerOf(&RandomBytesRequest::work_req_, work_req)); | ||
| 5790 | 5782 | Environment* env = req->env(); | |
| 5791 | 5783 | HandleScope handle_scope(env->isolate()); | |
| 5792 | 5784 | Context::Scope context_scope(env->context()); | |
| 5793 | 5785 | Local<Value> argv[2]; | |
| 5794 | - RandomBytesCheck(req, &argv); | ||
| 5786 | + RandomBytesCheck(req.get(), &argv); | ||
| 5795 | 5787 | req->MakeCallback(env->ondone_string(), arraysize(argv), argv); | |
| 5796 | - delete req; | ||
| 5797 | 5788 | } | |
| 5798 | 5789 | ||
| 5799 | 5790 | ||
| 5800 | 5791 | void RandomBytesProcessSync(Environment* env, | |
| 5801 | - RandomBytesRequest* req, | ||
| 5792 | + std::unique_ptr<RandomBytesRequest> req, | ||
| 5802 | 5793 | Local<Value> (*argv)[2]) { | |
| 5803 | 5794 | env->PrintSyncTrace(); | |
| 5804 | 5795 | RandomBytesWork(req->work_req()); | |
| 5805 | - RandomBytesCheck(req, argv); | ||
| 5806 | - delete req; | ||
| 5796 | + RandomBytesCheck(req.get(), argv); | ||
| 5807 | 5797 | ||
| 5808 | 5798 | if (!(*argv)[0]->IsNull()) | |
| 5809 | 5799 | env->isolate()->ThrowException((*argv)[0]); | |
@@ -5819,12 +5809,12 @@ void RandomBytes(const FunctionCallbackInfo<Value>& args) { | |||
| 5819 | 5809 | Local<Object> obj = env->randombytes_constructor_template()-> | |
| 5820 | 5810 | NewInstance(env->context()).ToLocalChecked(); | |
| 5821 | 5811 | char* data = node::Malloc(size); | |
| 5822 | - RandomBytesRequest* req = | ||
| 5812 | + std::unique_ptr<RandomBytesRequest> req( | ||
| 5823 | 5813 | new RandomBytesRequest(env, | |
| 5824 | 5814 | obj, | |
| 5825 | 5815 | size, | |
| 5826 | 5816 | data, | |
| 5827 | - RandomBytesRequest::FREE_DATA); | ||
| 5817 | + RandomBytesRequest::FREE_DATA)); | ||
| 5828 | 5818 | ||
| 5829 | 5819 | if (args[1]->IsFunction()) { | |
| 5830 | 5820 | obj->Set(env->ondone_string(), args[1]); | |
@@ -5837,13 +5827,13 @@ void RandomBytes(const FunctionCallbackInfo<Value>& args) { | |||
| 5837 | 5827 | } | |
| 5838 | 5828 | ||
| 5839 | 5829 | uv_queue_work(env->event_loop(), | |
| 5840 | - req->work_req(), | ||
| 5830 | + req.release()->work_req(), | ||
| 5841 | 5831 | RandomBytesWork, | |
| 5842 | 5832 | RandomBytesAfter); | |
| 5843 | 5833 | args.GetReturnValue().Set(obj); | |
| 5844 | 5834 | } else { | |
| 5845 | 5835 | Local<Value> argv[2]; | |
| 5846 | - RandomBytesProcessSync(env, req, &argv); | ||
| 5836 | + RandomBytesProcessSync(env, std::move(req), &argv); | ||
| 5847 | 5837 | if (argv[0]->IsNull()) | |
| 5848 | 5838 | args.GetReturnValue().Set(argv[1]); | |
| 5849 | 5839 | } | |
@@ -5866,12 +5856,12 @@ void RandomBytesBuffer(const FunctionCallbackInfo<Value>& args) { | |||
| 5866 | 5856 | char* data = Buffer::Data(args[0]); | |
| 5867 | 5857 | data += offset; | |
| 5868 | 5858 | ||
| 5869 | - RandomBytesRequest* req = | ||
| 5859 | + std::unique_ptr<RandomBytesRequest> req( | ||
| 5870 | 5860 | new RandomBytesRequest(env, | |
| 5871 | 5861 | obj, | |
| 5872 | 5862 | size, | |
| 5873 | 5863 | data, | |
| 5874 | - RandomBytesRequest::DONT_FREE_DATA); | ||
| 5864 | + RandomBytesRequest::DONT_FREE_DATA)); | ||
| 5875 | 5865 | if (args[3]->IsFunction()) { | |
| 5876 | 5866 | obj->Set(env->context(), env->ondone_string(), args[3]).FromJust(); | |
| 5877 | 5867 | ||
@@ -5883,13 +5873,13 @@ void RandomBytesBuffer(const FunctionCallbackInfo<Value>& args) { | |||
| 5883 | 5873 | } | |
| 5884 | 5874 | ||
| 5885 | 5875 | uv_queue_work(env->event_loop(), | |
| 5886 | - req->work_req(), | ||
| 5876 | + req.release()->work_req(), | ||
| 5887 | 5877 | RandomBytesWork, | |
| 5888 | 5878 | RandomBytesAfter); | |
| 5889 | 5879 | args.GetReturnValue().Set(obj); | |
| 5890 | 5880 | } else { | |
| 5891 | 5881 | Local<Value> argv[2]; | |
| 5892 | - RandomBytesProcessSync(env, req, &argv); | ||
| 5882 | + RandomBytesProcessSync(env, std::move(req), &argv); | ||
| 5893 | 5883 | if (argv[0]->IsNull()) | |
| 5894 | 5884 | args.GetReturnValue().Set(argv[1]); | |
| 5895 | 5885 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments