Re: Malloc code
- From: "Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx>
- Date: Wed, 2 Jan 2008 14:32:33 -0600
However, it is considered a good programming habit by some to set pointers
to null when the associated memory is released. That's to protect you from
yourself. If you accidently try to dereference the pointer after it has
been set to null, this will cause your program to crash. Imagine if you
didn't reset the pointer to 0. Then you would be using deallocated memory,
which usually leads to
Probably not. On embedded systems with no mmu, address zero is valid.
memory corruption. The problem is that your program is likely to trundle
along for quite some time before dying mysteriously and ignominously.
These kind of bugs are notoriously difficult to debug.
Scope control is really the only thing that helps when running without an
mmu.
.
- Follow-Ups:
- Re: Malloc code
- From: Brian Muth
- Re: Malloc code
- References:
- Re: Malloc code
- From: Robby
- Re: Malloc code
- From: Brian Muth
- Re: Malloc code
- Prev by Date: Re: Malloc code
- Next by Date: Re: Using TLSAlloc to read data into a DLL
- Previous by thread: Re: Malloc code
- Next by thread: Re: Malloc code
- Index(es):
Relevant Pages
|