Subject: Re: 0xdeadbeef memory reference
To: Ljubisa Milenkovic <>
From: Jaromír <>
List: tech-kern
Date: 07/06/2001 09:54:26
Ljubisa Milenkovic wrote:
> And to free:
> #define LFREE(t)             free (&t, M_TEMP)

Assuming the 't' is pointer to the previously allocated memory, this
is wrong and seems like it would cause ramdom piece of memory to be freed
(depending on where (t) came from, it could be stack or something else).
You should use 'free(t, M_TEMP)', and set (t) to NULL afterwards manually.

The freed memory contents are set to 0xdeadbeef to detect when memory
is used after it's freed, the idea being the bogus value would cause
a crash/panic. Really good for debugging. AFAIK it's only done in kernels
with DIAGNOSTIC option.

> If I set the pointer to point to NULL (after LFREE(p)) is that memory
> released?

Yes, of course. You can do whatever you like with the pointer
after the memory is freed via free(9).

Jaromir Dolecek <>
NetBSD - just plain best OS! -=*=- Got spare MCA cards or docs? Hand me them!