in c++, can reserve memory , delete memory, like:
float *myfloat; myfloat = new float[10]; delete myfloat; --> works fine however if type not float * mtransformationmatrix * (maya type), unable delete:
mtransformationmatrix *mytransformationmatrixes; mytransformationmatrixes = new mtransformationmatrix[10]; delete mytransformationmatrixes; --> crash is there need special types in order free memory ?
both of these allocated objects arrays, should use delete[] syntax delete them:
float *myfloat = new float[10]; delete[] myfloat; mtransformationmatrix *mytransformationmatrixes; mytransformationmatrixes = new mtransformationmatrix[10]; delete[] mytransformationmatrixes; both of examples invoke undefined behavior, lucky first 1 did not cause visible harm.
Comments
Post a Comment