#ifndef __PPT_ALLOCATOR_ #define __PPT_ALLOCATOR_ #include /************************************************************************** * Template name: heap_allocator * * Purpose: Allocator class to handle STL allocations * */ template class PtHeap_allocator : public std::allocator<_Ty> { public: PtHeap_allocator() { __hHeap = GetProcessHeap(); }; pointer allocate(size_type _N, const void *) {return (pointer) _Charalloc(_N * sizeof(_Ty)); } char* _Charalloc(size_type _N) {return (char*) HeapAlloc(__hHeap, 0, _N); } void deallocate(void* _P, size_type) {HeapFree(__hHeap, 0, _P); } private: HANDLE __hHeap; }; // Defines strings that use the above allocator to that the DMI heap stuff is used. #include #include typedef std::basic_string, PtHeap_allocator > PtStlString; typedef std::basic_string, PtHeap_allocator > PtStlWstring; #if 0// uses new allocator template > class PtStlMap : public std::map >{}; template class PtStlQueue : public std::queue > > {}; #else template > class PtStlMap : public std::map >{}; template class PtStlQueue : public std::queue > > {}; #endif #endif // __PPT_ALLOCATOR_