home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / chap02 / malloc2 / malloc2.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  2KB  |  79 lines

  1. /*
  2.  * MALLOC2.H
  3.  * C++ Malloc Demonstration Chapter 2
  4.  *
  5.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  6.  *
  7.  * Kraig Brockschmidt, Microsoft
  8.  * Internet  :  kraigb@microsoft.com
  9.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  10.  */
  11.  
  12.  
  13. #ifndef _MALLOC2_H_
  14. #define _MALLOC2_H_
  15.  
  16. #include <inole.h>
  17.  
  18. //Menu Resource ID and Commands
  19. #define IDR_MENU                1
  20.  
  21.  
  22. #define IDM_COGETMALLOC         100
  23. #define IDM_RELEASE             101
  24. #define IDM_ALLOC               102
  25. #define IDM_FREE                103
  26. #define IDM_REALLOC             104
  27. #define IDM_GETSIZE             105
  28. #define IDM_DIDALLOC            106
  29. #define IDM_HEAPMINIMIZE        107
  30. #define IDM_EXIT                108
  31.  
  32.  
  33.  
  34. //MALLOC2.CPP
  35. LRESULT APIENTRY MallocWndProc(HWND, UINT, WPARAM, LPARAM);
  36.  
  37. //How many allocations we'll perform
  38. #define CALLOCS 10
  39.  
  40.  
  41. class CApp
  42.     {
  43.     friend LRESULT APIENTRY MallocWndProc(HWND, UINT, WPARAM, LPARAM);
  44.  
  45.     protected:
  46.         HINSTANCE       m_hInst;            //WinMain parameters
  47.         HINSTANCE       m_hInstPrev;
  48.         UINT            m_nCmdShow;
  49.  
  50.         HWND            m_hWnd;             //Main window handle
  51.         IMalloc        *m_pIMalloc;         //From CoGetMalloc
  52.  
  53.         BOOL            m_fAllocated;       //We have allocations?
  54.         ULONG           m_rgcb[CALLOCS];    //Sizes to allocate
  55.         LPVOID          m_rgpv[CALLOCS];    //Allocated pointers
  56.  
  57.     public:
  58.         CApp(HINSTANCE, HINSTANCE, UINT);
  59.         ~CApp(void);
  60.         BOOL Init(void);
  61.  
  62.         void GetAllocator(void);
  63.         BOOL HaveAllocator(void);
  64.         BOOL DoAllocations(BOOL);
  65.         BOOL HaveAllocations(void);
  66.         void FreeAllocations(BOOL);
  67.  
  68.         void Message(LPTSTR);
  69.     };
  70.  
  71. typedef CApp *PAPP;
  72.  
  73.  
  74. #define CBWNDEXTRA              sizeof(PAPP)
  75. #define MALLOCWL_STRUCTURE      0
  76.  
  77.  
  78. #endif //_MALLOC2_H_
  79.