Any way to check size of dynamically allocted array in debug mode?
-
wrote on 7 Dec 2019, 01:47 last edited by kitfox 12 Jul 2019, 01:48
I have an application that I suspect is reading past the end of a float* buffer. Is there any way to see how many bytes have been allocated to this buffer when I've stopped at a breakpoint?
-
Use a std::vector / QVector instead plain memory.
-
I have an application that I suspect is reading past the end of a float* buffer. Is there any way to see how many bytes have been allocated to this buffer when I've stopped at a breakpoint?
wrote on 7 Dec 2019, 10:25 last edited by@kitfox
If you mean it's been allocated via e.g.new float[100]
or similar, then no. As @Christian-Ehrlicher has said, you would need to use a class like a vector which notes how big the allocation is and contains code to do bounds checking.
1/3