Checking if something was malloced

后端 未结 8 748
面向向阳花
面向向阳花 2021-01-12 07:06

Given a pointer to some variable.. is there a way to check whether it was statically or dynamically allocated??

8条回答
  •  爱一瞬间的悲伤
    2021-01-12 07:21

    You can compare its address to something you know to be static, and say it's malloced only if it's far away, if you know the scope it should be coming from, but if its scope is unknown, you can't really trust that.

提交回复
热议问题