Can you check the size memory allocated on heap if the buffer contains ‘0’ characters?
char *c = new char[6]; //random size memory
memset(c, 0, 6);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no reliable way to do that – you have to store that information yourself.
operator new[]()function can be implemented (and replaced by you) in whatever way so you just can’t know the size unless you know the exact implementation in details.In Visual C++ the default implementation for built-in types is to just forward calls to
malloc()– then you could try_msize(), but again it’s unportable and maybe even unreliable.