????2??????
#define MAX_FILE_LEN 128
//??????????
//1 ?????????????д?????
//2 ????????????д?????
//3 ??????????????????浽????У??????????????????й????????????
//????????????????????????
typedef struct _tagMemoryInfo
{
    void* addr;          //?????????????
    size_t size;         //????С
    _UL lineNum;      //?????????亯?????к?
    char fileName[MAX_FILE_LEN];  //?????
}MemoryInfo;
//???????????????????????????????union????????????next????????
union FreeList
{
    FreeList* next;
    MemoryInfo data;
};
typedef struct _tagBusyList
{
    _tagBusyList* next;
    MemoryInfo* data;
}BusyList;
//??????????????
#define FREE_LIST_INIT_LEN 16
//????????????
static FreeList* g_freeList = NULL;
//????????????????
static BusyList* g_busyList = NULL;
//?????ú?????????
static void _CreateFreeList(int initLen);
static void _ReleaseFreeList();
static void* _GetFreeNode();
static void* _GetBusyNode();
static void _FreeNode(void* p);
static void _WriteMemoryInfo(const MemoryInfo* pInfo ?? bool bAlloc);
static void _StoreMemoryAllocInfo(void* addr ?? size_t size ?? _UL lineNum ?? const char* file);
static void _StoreMemoryDeallocInfo(void* addr);
void* __cdecl operator new(unsigned int size ?? _UL lineNum ?? const char* file)
{
    void* p = ::operator new(size);
    _StoreMemoryAllocInfo(p ?? size ?? lineNum ?? file);
    return p;
    //return 0;
}
void __cdecl operator delete(void* p)
{
 _StoreMemoryDeallocInfo(p);
}
void __cdecl operator delete(void *p??  _UL lineNum ?? const char* file)
{
    lineNum;
 file;
    _StoreMemoryDeallocInfo(p);
}
void* __cdecl operator new[](unsigned int size ?? _UL lineNum ?? const char* file)
{
    void* p = ::operator new(size);
   
    _StoreMemoryAllocInfo(p ?? size ?? lineNum ?? file);
   
    return p;   
}
void __cdecl operator delete [] (void *p)
{
    _StoreMemoryDeallocInfo(p);
}
void __cdecl operator delete [] (void *p ??  _UL lineNum ?? const char* file)
{
 lineNum;
 file;
 _StoreMemoryDeallocInfo(p);
}
void* __cdecl _DebugMalloc(size_t size ?? _UL lineNum ?? const char* file)
{
    void* p = malloc(size);
 _StoreMemoryAllocInfo(p ?? size ?? lineNum ?? file);
 return p;
}
void* __cdecl _DebugCalloc(size_t num ?? size_t size ?? _UL lineNum ?? const char* file)
{
 void* p = calloc(num ?? size);
 _StoreMemoryAllocInfo(p ?? num * size ?? lineNum ?? file);
 return p;
}
void  __cdecl _DebugFree(void* addr)

 _StoreMemoryDeallocInfo(addr); 
}
//???????????????????????????????????????????????
//????????????????????????????????????????????????ó?????????
void _CreateFreeList(int initLen)
{
    FreeList* p = (FreeList*)malloc(sizeof(FreeList) * initLen);
    g_freeList = p;
    for (int idx = 1; idx < initLen; ++idx)
    {
        p->next = p + idx;
        p++;
    }
    p->next = NULL;
}
void* _GetFreeNode()
{
    if ( g_freeList == NULL)
    {
        _CreateFreeList(FREE_LIST_INIT_LEN);
        if ( NULL == g_freeList )
        {
            return NULL;
        }
    }
   
    FreeList* p = g_freeList;   
    g_freeList = g_freeList->next;
    return (void*)p;
}