WdfDeviceInitFree function

[Applies to KMDF only]

The WdfDeviceInitFree method deallocates a WDFDEVICE_INIT structure.

Syntax

void WdfDeviceInitFree(
  PWDFDEVICE_INIT DeviceInit
);

Parameters

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

   
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, DriverCreate, InitFreeDeviceCallback, InitFreeDeviceCreate, InitFreeDeviceCreateType2, InitFreeDeviceCreateType4, InitFreeNull, KmdfIrql, KmdfIrql2, PdoInitFreeDeviceCallback, PdoInitFreeDeviceCreate, PdoInitFreeDeviceCreateType2, PdoInitFreeDeviceCreateType4

See Also

WdfDeviceCreate