Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // File: shalloc.h
  4. //
  5. // Contents: CSHAlloc
  6. //
  7. // Purpose: A wrapper class for the shell's task allocator. Loads the
  8. // shell's allocator on first contstruction, and if that fails,
  9. // subsequent uses of this allocator will fail as appropriate.
  10. //
  11. //--------------------------------------------------------------------------
  12. #ifndef __SHALLOC_H__
  13. #define __SHALLOC_H__
  14. #include <shlobj.h>
  15. class CSHAlloc : public IMalloc
  16. {
  17. IMalloc * m_pMalloc;
  18. DWORD m_cRefs;
  19. public:
  20. CSHAlloc(BOOL bInitOle = TRUE);
  21. ~CSHAlloc();
  22. // IUnknown methods
  23. STDMETHOD(QueryInterface) (THIS_ REFIID riid, void * * ppvObj);
  24. STDMETHOD_(ULONG, AddRef) (THIS_);
  25. STDMETHOD_(ULONG, Release) (THIS_);
  26. // IMalloc methods
  27. STDMETHOD_(void *, Alloc) (THIS_ SIZE_T cb);
  28. STDMETHOD_(void, Free) (THIS_ void * pv);
  29. STDMETHOD_(void *, Realloc) (THIS_ void * pv, SIZE_T cb);
  30. STDMETHOD_(SIZE_T, GetSize) (THIS_ void * pv);
  31. STDMETHOD_(int, DidAlloc) (THIS_ void * pv);
  32. STDMETHOD_(void, HeapMinimize)(THIS_);
  33. };
  34. // App must declare a global instance of this class
  35. extern CSHAlloc g_SHAlloc;
  36. #endif // __SHALLOC_H__