首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

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

2013-01-02 
C++开发驱动中的重载问题template POOL_TYPE PoolType class CAllocator{public:void* operator new(uns

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;

热点排行