does exit() free allocated memory on both _SUCCESS and _FAILURE

前端 未结 4 2475
旧时难觅i
旧时难觅i 2021-02-19 16:43

This a short snippet of code, with two calls to exit(3) in case of failure. Do these calls deallocate memory allocated by malloc? Google search once says it does, a

4条回答
  •  名媛妹妹
    2021-02-19 17:16

    When you exit the program, all allocated memory is reclaimed by the OS (both the stack and the heap). Your program doesn't leave any footprint in the RAM, unless you work outside the program's memory through buffer overflows and such.

提交回复
热议问题