[SOLVED] Error C2440: while allocating a memory to the miniport adapter RRS feed

  • Question

  • Dear developers,


    As, I am getting a compile time error C2440: cannot convert PVOID to PPHY_ADAPTER when i use the below function:-

    PPHY_ADAPTER	pAdapter	= NULL;
    pAdapter = NdisAllocateMemoryWithTagPriority(hMiniportAdapterHandle,

    Then, I checked that return type go NdisAllocateMemoryWithTagPriority is PVOID and I was using different datatype.

    Then, I put some efforts and take the reference code and modified my code as :-

    #define MP_ALLOCATE_MEMORY_WITH_PRIORITY(_NdisHandle, _ppMemory, _ulSizeInBytes, _ulTag, _Priority) \
        *_ppMemory = NdisAllocateMemoryWithTagPriority (                    \
            _NdisHandle,                                                    \
            _ulSizeInBytes,                                                 \
            _ulTag,                                                         \
            _Priority                                                       \
    #define  MP_ALLOCATE_MEMORY(_NdisHandle, _ppMemory, _ulSizeInBytes, _ulTag) \
        MP_ALLOCATE_MEMORY_WITH_PRIORITY(_NdisHandle, _ppMemory, _ulSizeInBytes, _ulTag, NormalPoolPriority)
    /*---- Allocating a memory to the adapter */	
    			MP_ALLOCATE_MEMORY(hMiniportAdapterHandle, &pAdapter, sizeof(PHY_ADAPTER), MEM_TAG_ADAPTER);
    			if(pAdapter == NULL){
    				DEBUGMSG(TRUE,(TEXT("phytec_allocate_adapter: Failed to allocate %d bytes of memory for the Adapter	\n"),sizeof(PHY_ADAPTER)));
    				status = NDIS_STATUS_RESOURCES;

    But, still the nature of the error is same.... When I compiled the referenced code, i dont get any error...

    Friday, November 20, 2015 5:42 AM

All replies

  • Dear Developers,


    Is this the correct way of coding

    #define MEM_TAG ((ULONG('DCBA'))
    MY_ADAPTER *pMyAdapter;
    . . .
    // Allocate an adapter context area:
    (PVOID)pMyAdapter = NdisAllocateMemoryWithTagPriority (
                        NdisMiniportDriverHandle, sizeof(MY_ADAPTER),
                        MEM_TAG, LowPoolPriority);
    // Clear the context area:
    NdisZeroMemory(pMyAdapter, sizeof(MY_ADAPTER));

    specially for (PVOID)pMyAdapter;

    Actually, I got this from the MSDN and here is the link..

    Friday, November 20, 2015 11:06 AM