what happens when tried to free memory allocated by heap manager, which allocates more than asked for?

后端 未结 5 2132
忘了有多久
忘了有多久 2021-02-15 10:48

This question was asked to me in an interview.

Suppose char *p=malloc(n) assigns more than n,say N bytes of memory are allocated and free(p) is used to free the memory a

5条回答
  •  悲哀的现实
    2021-02-15 11:13

    Other answers have explained well how the block size is handled. To find out how much memory is freed, the only solution I can think of is to call mallinfo() before and after the free.

提交回复
热议问题