diff --git a/src/object_async/hello_async.cpp b/src/object_async/hello_async.cpp index adbe8ea..852741e 100644 --- a/src/object_async/hello_async.cpp +++ b/src/object_async/hello_async.cpp @@ -69,17 +69,17 @@ NAN_METHOD(HelloObjectAsync::New) { */ std::string name(*utf8_value, static_cast(len)); - /** + /** * This line is where HelloObjectAsync takes ownership of "name" with the use of move semantics. * Then all later usage of "name" are passed by reference (const&), but the actual home or address in memory * will always be owned by this instance of HelloObjectAsync. Generally important to know what has ownership of an object. * When a object/value is a member of a class (like "name"), we know the class (HelloObjectAsync) has full control of the scope of the object/value. * This avoids the scenario of "name" being destroyed or becoming out of scope. - * + * * Also, we're using "new" here to create a custom C++ class, based on node::ObjectWrap since this is a node addon. - * In this case, "new" allocates a C++ object (dynamically on the heap) and then passes ownership (control of when it gets deleted) + * In this case, "new" allocates a C++ object (dynamically on the heap) and then passes ownership (control of when it gets deleted) * to V8, the javascript engine which decides when to clean up the object based on how its’ garbage collector works. - * In other words, the memory of HelloObjectAsync is expliclty deleted via node::ObjectWrap when it's gone out of scope + * In other words, the memory of HelloObjectAsync is expliclty deleted via node::ObjectWrap when it's gone out of scope * (the object needs to stay alive until the V8 garbage collector has decided it's done): * https://github.com/nodejs/node/blob/7ec28a0a506efe9d1c03240fd028bea4a3d350da/src/node_object_wrap.h#L124 **/ @@ -155,7 +155,7 @@ struct AsyncHelloWorker : Nan::AsyncWorker // NOLINT to disable cppcoreguideline AsyncHelloWorker(bool louder, const std::string* name, Nan::Callback* cb) - : Base(cb), , louder_{louder}, name_{name} {} + : Base(cb), result_{}, louder_{louder}, name_{name} {} // NOLINT TODO: disable misc-unused-parameters check // The Execute() function is getting called when the worker starts to run. // - You only have access to member variables stored in this worker. diff --git a/src/standalone_async/hello_async.cpp b/src/standalone_async/hello_async.cpp index 9d09105..ae9f0d4 100644 --- a/src/standalone_async/hello_async.cpp +++ b/src/standalone_async/hello_async.cpp @@ -72,7 +72,7 @@ struct AsyncHelloWorker : Nan::AsyncWorker { using Base = Nan::AsyncWorker; AsyncHelloWorker(bool louder, Nan::Callback* cb) - : Base(cb), , louder_{louder} {} + : Base(cb), result_{}, louder_{louder} {} // NOLINT TODO: disable misc-unused-parameters check // The Execute() function is getting called when the worker starts to run. // - You only have access to member variables stored in this worker.