none
How is definition of new and delete operators in C? RRS feed

  • Question

  • I have these definitions of new and delete operators, works fine in C++, but in C the IDE generates a error that say:


    expected a ';'

    How fix this?

    void* __cdecl operator new(size_t size, POOL_TYPE PoolType)
    {
    	return ExAllocatePool(PoolType, size);
    }
    
    void* __cdecl operator new[](size_t size, POOL_TYPE PoolType)
    {
    	return ExAllocatePool(PoolType, size);
    }
    
    void __cdecl operator delete(PVOID pv)
    {
    	ExFreePool(pv);
    }
    
    void __cdecl operator delete(PVOID pv, size_t)
    {
    	ExFreePool(pv);
    }
    
    void __cdecl operator delete[](PVOID pv)
    {
    	ExFreePool(pv);
    }


     
    • Edited by FL4SHC0D3R Sunday, March 25, 2018 3:28 PM
    Sunday, March 25, 2018 3:27 PM

Answers

  • The new and delete operators are for classes and C does not have classes.


    Sam Hobbs
    SimpleSamples.Info

    • Marked as answer by FL4SHC0D3R Sunday, March 25, 2018 5:07 PM
    Sunday, March 25, 2018 3:43 PM