I am grading a bunch of student assignments.
They are designing their own dynamic array data type. I am looking for a good way to test to make sure that they malloc the correct amount of memory for an array when re-sizing.
Other than inspecting the code is there some way to easily test the amount of memory created by a malloc call? They are supposed to keep track of the capacity but I need to test that they are doing so correctly.
I would also like it if the test didn't end in a segfault if they did not allocate enough memory so that I could continue running other tests.
Thanks!