> I tried free and delete, but the values are still there.
Well you used calloc() to allocate the memory, so the correct function to use is free(), as in
The second point is that unless you're using specific kinds of debug allocators, you can "peek behind the curtain" and still see the original data. It's one of the problems which makes 'use-after-free' errors so hard to spot, because hey it works - until it doesn't work.
Examples of debug allocators include features such as
- filling the memory with a recognisable pattern such as 0xCD.
- putting each memory block in its own memory page, then marking the page as invalid after free.
But these debug features are a performance hit, so they're only typically enabled when you're looking for problems.
Don't worry, the memory really is freed. The next time you call malloc/calloc, chances are that memory will be reused for it's new purpose.