// wdfdevice.h
VOID WdfDeviceInitFree(
[in] PWDFDEVICE_INIT DeviceInit
);
View the official Windows Driver Kit DDI reference
No description available.
[Applies to KMDF only]
The WdfDeviceInitFree method deallocates a WDFDEVICE_INIT structure.
DeviceInit
[in]A pointer to a WDFDEVICE_INIT structure.
If your driver receives a WDFDEVICE_INIT structure from a call to WdfPdoInitAllocate or WdfControlDeviceInitAllocate, and if the driver subsequently encounters an error when it calls a device object initialization method or WdfDeviceCreate, the driver must call WdfDeviceInitFree.
Your driver must not call WdfDeviceInitFree after it calls WdfDeviceCreate successfully.
Your driver does not need to call WdfDeviceInitFree if it received the WDFDEVICE_INIT structure as input to its EvtDriverDeviceAdd callback function, because the framework deletes the structure after the callback function returns.
For more information about calling WdfDeviceCreate, see Creating a Framework Device Object.
The following code example calls WdfDeviceInitFree if a call to WdfPdoInitAssignRawDevice fails.
NTSTATUS status;
status = WdfPdoInitAssignRawDevice(
pDeviceInit,
&GUID_DEVCLASS_KEYBOARD
);
if (!NT_SUCCESS(status)) {
WdfDeviceInitFree(pDeviceInit);
pDeviceInit = NULL;
return STATUS;
}