WdfDeviceInitFree function (wdfdevice.h)
[Applies to KMDF only]
The WdfDeviceInitFree method deallocates a WDFDEVICE_INIT structure.
Syntax
void WdfDeviceInitFree(
[in] PWDFDEVICE_INIT DeviceInit
);
Parameters
[in] DeviceInit
A pointer to a WDFDEVICE_INIT structure.
Return value
None
Remarks
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.
Examples
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;
}
Requirements
Requirement | Value |
---|---|
Target Platform | Universal |
Minimum KMDF version | 1.0 |
Header | wdfdevice.h (include Wdf.h) |
Library | Wdf01000.sys (see Framework Library Versioning.) |
IRQL | <= DISPATCH_LEVEL |
DDI compliance rules | DoubleDeviceInitFree(kmdf), DriverCreate(kmdf), InitFreeDeviceCallback(kmdf), InitFreeDeviceCreate(kmdf), InitFreeDeviceCreateType2(kmdf), InitFreeDeviceCreateType4(kmdf), InitFreeNull(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf), PdoInitFreeDeviceCallback(kmdf), PdoInitFreeDeviceCreate(kmdf), PdoInitFreeDeviceCreateType2(kmdf), PdoInitFreeDeviceCreateType4(kmdf) |