Subject: 0xdeadbeef memory reference
To: 'tech-kern@netbsd.org' <tech-kern@netbsd.org>
From: Ljubisa Milenkovic <ljubisa.milenkovic@reddo.net>
List: tech-kern
Date: 07/06/2001 09:20:27
Hello,

I'm working on a NAT implementation for NetBSD for our specific usage of
NetBSD. I came to a point where I need to ask a kernel question.
After I release memory I allocated, the pointer reference to following
addresses: 0xdeadbeef and 0xdead(xxxx) where xxxx are numbers. Did I release
that memory?

To allocate memory I use following macros:

#define NEW(t)         (t *) malloc ((u_long) sizeof (t), M_TEMP, M_NOWAIT)
/**< Returns a pointer to type t */
#define VNEW(t, n)     (t *) malloc ((u_long) n * (u_long) sizeof (t),
M_TEMP, M_NOWAIT)   /**< Returns a pointer to array of type t */

And to free:
#define LFREE(t)             free (&t, M_TEMP)
/**< Frees the allocated memory */
 
Is there something wrong with my macros?

I would like to test if the released pointer is free. For that I use a IF
statement:
If (pointer != NULL)
But pointer points to 0xdeadbeef and not NULL.
If I set the pointer to point to NULL (after LFREE(p)) is that memory
released?

Thanks for response.

Regards Ljuba

Ljubisa Milenkovic
Reddo Networks AB
phone: +46 73 942 24 45
e-mail: Ljubisa.Milenkovic@reddo.net