DHCP Callout API Memory Allocation

From: Duckmonkeyman (Duckmonkeyman_at_discussions.microsoft.com)
Date: 02/28/05


Date: Mon, 28 Feb 2005 11:59:04 -0800

I'm using LocalAlloc() and LocalFree() in the DhcpNewPktHook and
DhcpPktSendHook functions to manage both the PktContext and the Packet.

- Is LocalAlloc() and LocalFree() what I should be using in the callout DLL
to allocate and free memory? Or should I allocate dynamic memory a different
way?

- Do I need to deallocate the *Packet passed in if I resize it, reallocate,
and return a new Packet? Right now, doing an LocalFree(*Packet) causes the
DHCP server to crash. Removing this LocalFree() stops the crashing, but am I
then leaking memory? In other words, does the DHCP Server handle
deallocating the *Packet passed in? Does it also deallocate the *PktContext?

Thanks.