Expand Minimize

WdfDeviceInitFree method

[Applies to KMDF only]

The WdfDeviceInitFree method deallocates a WDFDEVICE_INIT structure.

Syntax


VOID WdfDeviceInitFree(
  [in]  PWDFDEVICE_INIT DeviceInit
);

Parameters

DeviceInit [in]

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 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.

Your driver must not call WdfDeviceCreate after it calls WdfDeviceInitFree.

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

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

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.