// cnct_tbl.cpp // // class CConnectionTable // // CConnectionTable maps connection numbers (as returned by ::Advise()) // to clipformat's for DDE advise connections. #include "ddeproxy.h" #include "cnct_tbl.h" ASSERTDATA #define grfMemFlags (GMEM_MOVEABLE | GMEM_ZEROINIT) // number of INFO entries to grow by #define cinfoBlock 10 typedef struct INFO { BOOL fUsed; // is this table entry used? DWORD dwConnection; // search key CLIPFORMAT cf; // corresponding cf, for use in DDE_(UN)ADVISE DWORD grfAdvf; // ON_CHANGE or ON_SAVE or ON_CLOSE } INFO, FAR* PINFO; CDdeConnectionTable::CDdeConnectionTable () { m_h = GlobalAlloc (grfMemFlags, cinfoBlock * sizeof(INFO)); Assert (m_h); m_cinfo=cinfoBlock; } CDdeConnectionTable::~CDdeConnectionTable () { Assert(m_h); m_h =GlobalFree (m_h); Assert (m_h==NULL); m_cinfo=0; } INTERNAL CDdeConnectionTable::Add (DWORD dwConnection, CLIPFORMAT cf, DWORD grfAdvf) { Start: PINFO rginfo; if (NULL==(rginfo = (PINFO) GlobalLock(m_h))) { Puts ("ERROR: CDdeConnectionTable::Add out of memory\n"); return ReportResult(0, E_OUTOFMEMORY, 0, 0); } // Look for an empty table entry for (DWORD i=0; i