Hi, 

I am doing a matrix test, porting a matrix lib to JS
the code for operator "=" is very simple, just memcpy

Matrix4x4& Matrix4x4::operator = ( const Matrix4x4& mat )
{
   const float* pRHSEntries = mat.GetEntries();
   memcpy( (void*)m_pEntries, (const void*)pRHSEntries, sizeof(m_pEntries) 
);
   return *this;
} 

And I bind this oeprator to "CopyFrom" 
class_<Matrix4x4>("Matrix4x4")
.function("CopyFrom", &Matrix4x4::operator = )


In my JS test, I call CopyFrom in a loop for 1,000,000 times, like this:

var mat1 = new Module.Matrix4x4();
var mat2 = new Module.Matrix4x4();
  
for ( var i = 0; i < 1000000; ++i )
{
// just assign matrix value
mat2.CopyFrom( mat1 );
}

It will get the "Cannot enlarge memory arrays" error ( but calling only 
100,000 times is ok )
Since there is not any memory allocation in my operator =, it simply gets 
the pointers and does a memcpy
So I don't understand why the memory is insufficient...

Any idea ?

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to