Re: finding out if pointer to memory is valid
On Thu, 26 Jun 2003 12:13:52 -0700, Schelli wrote:
> ok, i got 2 pointers pointing to same memory/object. with one of the
> pointers i delete the object and i could set this pointer to NULL to
> know that it was deleted, but the other pointer still remains pointed
> there and does not "know" the memory was deleted. so if i now access
> this memory i might get a crash !
> now if i switch codeguard (BC++ 6.0) on, he immediately says accessing
> non reserved memory, or something like this, although the program does
> not crash yet, well, sometimes it does, but thats by chance of course.
> can i somehow find out that the memory this pointer is pointing to was
> deleted ? or do i just have to find a way to set the other pointer to
> NULL so i know.
You could use a reference to a pointer, so that if you set any one to NULL,
all of them become NULL. I don't know if this will fit in with your design
|All times are GMT. The time now is 05:24 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.