Free structure and the heap

前端 未结 3 1246
名媛妹妹
名媛妹妹 2021-01-27 11:44

If we have a structure that has pointers to malloced memory and then if we free that structure, is the memory referenced by that structure also freed? or do we have to free it m

3条回答
  •  猫巷女王i
    2021-01-27 12:25

    is the memory referenced by that structure also freed? or do we have to free it manually?

    The latter.

    Each memory block dynamically allocated needs a separate call to free().

提交回复
热议问题