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?
There could be a problem if someone overrides
operator newfor your type.It is just as easy to write
or, if you really write C++