File tree Expand file tree Collapse file tree
generate/templates/partials Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,20 +56,21 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
5656 {% if arg.cppClassName == ' Array' %}
5757 {
5858 v8::Local<v8::Array> tempArray = v8::Local<v8::Array>::Cast (info[{{ arg.jsArg }}]);
59- baton->{{ arg.name }} = new {{ arg.cType |unPointer }}[ tempArray->Length ()] ;
59+ baton->{{ arg.name }} = ({{ arg. cType |unPointer }}*) malloc ( sizeof ( {{ arg.cType |unPointer }}) * tempArray->Length ()) ;
6060 for (uint32_t i = 0 ; i < tempArray->Length (); ++i) {
6161 auto conversionResult = Configurable{{ arg.arrayElementCppClassName }}::fromJavascript (
6262 nodegitContext,
6363 Nan::Get (tempArray, i).ToLocalChecked ()
6464 );
6565
6666 if (!conversionResult.result ) {
67- delete[] baton->{{ arg.name }};
67+ // TODO free previously allocated memory
68+ free (baton->{{ arg.name }});
6869 return Nan::ThrowError (Nan::New (conversionResult.error ).ToLocalChecked ());
6970 }
7071
7172 auto convertedObject = conversionResult.result ;
72- cleanupHandles[" {{ arg.name }}" ] = convertedObject;
73+ cleanupHandles[std::string ( " {{ arg.name }}" ) + std::to_string (i) ] = convertedObject;
7374 baton->{{ arg.name }}[i] = *convertedObject->GetValue ();
7475 }
7576 }
You can’t perform that action at this time.
0 commit comments