Why exactly should I not call free() on variables not allocated by malloc()?

前端 未结 7 681
我寻月下人不归
我寻月下人不归 2020-12-01 17:32

I read somewhere that it is disastrous to use free to get rid of an object not created by calling malloc, is this true? why?

7条回答
  •  情深已故
    2020-12-01 17:52

    Strictly speaking, this is not true. calloc() and realloc() are valid object sources for free(), too. ;)

提交回复
热议问题