I am converting a C code to C++.
There is matrix pointer:
MATRIX* matrix = NULL;
matrix = new MATRIX[256];
if (matrix == NULL)
return FAIL;
memset(matrix, 0, 256*sizeof(MATRIX));
Then it was filled on a different method:
fillUpMatrix(matrix);
And in fillUpMatrix():
memcpy(&matrix[start], &someOtherMatrix[pos], sizeof(MATRIX));
And later on memset was called for the pointer since it will be filled with a different set of values:
memset(matrix, 0, 256*sizeof(MATRIX));
So what I did was:
auto matrix= std::make_unique<MATRIX[]>(256);
fillUpMatrix(matrix.get());
I skipped the first memset since I believe I do not need it anymore for smart pointers.
But the second memset I believe is needed (since new values will be saved). So how do I write that in C++ and considering that I am using a smart pointer? Is my conversion above correct?