Figure 3: The information structure and map type used to keep track of allocated blocks

struct SMEMALLOC
{
   LPVOID      pAddr;       // Allocated address via malloc()
   size_t      nSize;       // Block size
   const char* pszFilename; // Filename
   int         nLine;       // Line number
};

typedef SMEMALLOC *  LPMEMALLOC;

// Build a SMEMALLOC map type, where each item associates an 
// address returned by malloc() to a description of the statement 
// allocating memory.

typedef CTypedPtrMap<CMapPtrToPtr, LPVOID, LPMEMALLOC> CAddrMap;