检查释放的指针...... [英] Checking freed pointer...
问题描述
嗨''身体,
有没有办法检查指针是否指向一个释放的内存
位置?
frakie写道:
嗨''身体,
有没有检查指针是否指向释放的内存的方法
位置?
非使用标准设施。你可以而且应该自己跟踪这个
信息。你究竟是这样做取决于你和项目
的要求。
一个简单的方法是将任何指针设置为NULL />
初始化为指向有效存储空间,或者此类存储空间已被释放。
On 3 Ott,11:43, santosh< santosh .... @ gmail.comwrote:
frakie写道:
嗨' 'body,
有没有办法检查指针是否指向一个释放的内存
位置?
非使用标准设施。你可以而且应该自己跟踪这个
信息。你究竟是这样做取决于你和项目
的要求。
一个简单的方法是将任何指针设置为NULL />
初始化为指向有效存储,或者此类存储已被释放。
D''哦!
谢谢..
< br>
frakie写道:
On 3 Ott,11:43,santosh< santosh .... @ gmail.comwrote:
> frakie写道:
嗨''正文,
有没有办法检查一个指针是否指向一个释放的内存
位置?
非使用标准设施。您可以而且应该自己跟踪这些信息。你究竟是如何做到取决于你和项目的要求。
一个简单的方法是将任何尚未初始化的指针设置为NULL以指向有效存储,或者这种存储已经免费。
D''哦!
谢谢..
注意这个方法/不起作用/如果指针值被复制;
将一个释放指针的副本设置为null不会对另一个做任何事情
副本,现在持有非空无效值。
您需要一个经过严格遵守的全球政策。
- -
Chris"例如,在转让或参数传递或......时Dollin
Hewlett-Packard Limited Cain Road,Bracknell,注册号:
注册办事处:Berks RG12 1HN 690597 England
Hi ''body,
is there a method to check if a pointer is pointing a freed memory
location?
frakie wrote:
Hi ''body,
is there a method to check if a pointer is pointing a freed memory
location?Non by using Standard facilities. You could, and should, keep track of this
information yourself. How exactly you do so is up to you and the projects
requirements.
One simple method is to set to NULL any pointer that has not been
initialised to point to valid storage, or such storage has been free''ed.
On 3 Ott, 11:43, santosh <santosh....@gmail.comwrote:frakie wrote:Hi ''body,
is there a method to check if a pointer is pointing a freed memory
location?
Non by using Standard facilities. You could, and should, keep track of this
information yourself. How exactly you do so is up to you and the projects
requirements.
One simple method is to set to NULL any pointer that has not been
initialised to point to valid storage, or such storage has been free''ed.D''oh!
Thank you..
frakie wrote:
On 3 Ott, 11:43, santosh <santosh....@gmail.comwrote:>frakie wrote:Hi ''body,
is there a method to check if a pointer is pointing a freed memory
location?
Non by using Standard facilities. You could, and should, keep track of this
information yourself. How exactly you do so is up to you and the projects
requirements.
One simple method is to set to NULL any pointer that has not been
initialised to point to valid storage, or such storage has been free''ed.
D''oh!
Thank you..Note this this method /does not work/ if pointer values get copied around;
setting one copy of a freed pointer to null won''t do anything to the other
copies, which now hold non-null non-valid values.
You need a carefully-followed global policy.
--
Chris "eg on assignment or parameter passing or ..." Dollin
Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
这篇关于检查释放的指针......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!