Is it safe to use _msize with new[]?

c, c++, mfc, visual-c++, visual-studio-2010

Solution

There could be a problem if someone overrides `operator new` for your type.

It is just as easy to write

const size_t s = 100;
int* i = new int[s];

or, if you really write C++

std::vector<int>   i(100);

Problem

Is it safe to use Microsoft specific _msize() function with new []? Example: ``` int* i = new int[100]; size_t s = _msize(i); cout << "Size of the array in bytes: " << s << endl; delete [] i; ``` MSDN does describe just the usage with malloc & Co. I've tested the code with Visual Studio 2010, and it looks to work! But i would like to know if there are some expected issues or any special cases?

Original source