当前位置:编程学习 > C/C++ >>

C++开发驱动中的重载问题

template <POOL_TYPE PoolType> class CAllocator
{
public:
 
    void* operator new(unsigned int size)
    {
        return ExAllocatePoolWithTag(PoolType, size, OSNTAG);
    }
 
    void* operator new[](unsigned int size)
    {
        return ExAllocatePoolWithTag(PoolType, size, OSNTAG);
    }
 
    PVOID operator new (size_t Size, void *addr)
    {
        return addr;
    }
 
    VOID operator delete(PVOID pMemory)
    {
        if(pMemory!=NULL)
            ExFreePool(pMemory);
    }
 
    VOID operator delete[](PVOID pMemory)
    {
        if(pMemory!=NULL)
            ExFreePool(pMemory);
    }
};
 
typedef CAllocator<NonPagedPool> CNPAllocator;
typedef CAllocator<PagedPool> CPAllocator;
补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,